Skip to content

Adding keymaps for specific surround commands #876

Closed Answered by echasnovski
firubat asked this question in Q&A
Discussion options

You must be logged in to vote

By default vim.keymap.set() treats keys in right hand side as if they have default meaning, i.e. no remap, i.e. "noremap".
You can achieve what you want by adding remap = true option. Like this:

vim.keymap.set({ "x" }, "s(", "sa(", { remap = true, desc = "Surround selection with ()" })

Just in case: this approach for adding surrounding will work only in Visual mode. In Normal mode there needs to be a target (textobject/motion) after sa.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@firubat
Comment options

Answer selected by firubat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants