`vim.keymap.set` not working but `vim.api.nvim_set_keymap`

Previously I was using the following binding for surrounding a visual selection with two asterisks for Markdown (with tpope/vim-surround):

vim.api.nvim_set_keymap("v", ",*", "S*gvS*", { noremap = false })

However, it doesn’t seem to work with vim.keymap.set, replacing the whole line with *gvS*.

vim.keymap.set("v", ",*", "S*gvS*", { noremap = false })

Is there anything I can do to resolve this issue?

vim.keymap.set ignores noremap (getting rid of that weird double negative is one of the points of this API). You need to set remap = true.

2 Likes

Ahh that clears it up. Thanks!!