[surround] Short keymap for frenquently used surround #2195
-
Contributing guidelines
Module(s)mini.surround QuestionI have mini.surround set up this way (Lazyvim default) {
"nvim-mini/mini.surround",
keys = function(_, keys)
-- Populate the keys based on the user's options
local opts = LazyVim.opts("mini.surround")
local mappings = {
{ opts.mappings.add, desc = "Add Surrounding", mode = { "n", "x" } },
{ opts.mappings.delete, desc = "Delete Surrounding" },
{ opts.mappings.find, desc = "Find Right Surrounding" },
{ opts.mappings.find_left, desc = "Find Left Surrounding" },
{ opts.mappings.highlight, desc = "Highlight Surrounding" },
{ opts.mappings.replace, desc = "Replace Surrounding" },
{ opts.mappings.update_n_lines, desc = "Update `MiniSurround.config.n_lines`" },
}
mappings = vim.tbl_filter(function(m)
return m[1] and #m[1] > 0
end, mappings)
return vim.list_extend(mappings, keys)
end,
opts = {
mappings = {
add = "gsa", -- Add surrounding in Normal and Visual modes
delete = "gsd", -- Delete surrounding
find = "gsf", -- Find surrounding (to the right)
find_left = "gsF", -- Find surrounding (to the left)
highlight = "gsh", -- Highlight surrounding
replace = "gsr", -- Replace surrounding
update_n_lines = "gsn", -- Update `n_lines`
},
},
}I use the surround My problem is : if I simply do this vim.keymap.set("n", "gs`", "gsaiw`")Neovim doesn't understand that the Mini.surround does not seem to expose commands. I took a look at the code, I believe it may be done by calling Did anyone manage to perform that trick ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That's because vim.keymap.set("n", "gs`", "gsaiw`", { remap = true }) |
Beta Was this translation helpful? Give feedback.
That's because
vim.keymap.setby default usesnoremapvariant 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: