How to prepend \<C-U>
to vim.cmd
API?
#24055
-
Hi, I am writing a key map util function: local function exec(op)
if type(op) == "string" then
-- vim command
vim.cmd(op)
else
-- lua function
op()
end
end
local function map(mode, lhs, rhs, opts)
opts = vim.tbl_deep_extend("force", {silent=true, noremap=true}, opts or {})
vim.keymap.set(mode, lhs, rhs, opts)
end
-- here define some key mappings
map({'n', 'x'}, '<leader>f', exec('echo hello')) But now, I have a specific requirement, that I want to get the block-wise visual selection. based on this: https://stackoverflow.com/a/61486601/4438921, I found that I have to use vimscript to define key mapping: xnoremap <leader>f :\<C-U> call GetVisualSelection(visualmode())<cr> How could I do it in lua? |
Beta Was this translation helpful? Give feedback.
Answered by
TheLeoP
Jun 19, 2023
Replies: 1 comment 9 replies
-
I think |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this context, those keys only delete
'<,'>
because it gets automatically inserted in the command line when you press:
on visual mode. If you check:h c_ctrl-u
you will see that this is what<c-u>
does in command mode.