Skip to content
Discussion options

You must be logged in to vote

My problem is : if I simply do this

vim.keymap.set("n", "gs`", "gsaiw`")

Neovim doesn't understand that the gsa part of the command means "Add a surround", it will perform a regular Neovim keymap. gs doesn't do anything in my config, but then a toggles insert mode. Instead of adding a surround around the current word, my keymap inserts iw` in the middle of it.

That's because vim.keymap.set by default uses noremap variant of the mapping, which means that keys are treated as if they are not mapped (i.e. as default). Adding { remap = true } as fourth argument should fix the issue. So something like this:

vim.keymap.set("n", "gs`", "gsaiw`", { remap = true })

Replies: 1 comment 1 reply

Comment options

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

Answer selected by echasnovski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested mini.surround
2 participants