New answers tagged

1 vote

keybindings that change mode: cannot use keybindings on the new mode

The key code is actually remap and not noremap. I would define it like this: local opts = { remap = false } local ll = "<leader>i" opts["desc"] = "Send visual lines&...
Vivian De Smedt's user avatar
0 votes

Best way to keybind subsequent substitutions in visual mode

I would probably write xnoremap <leader>q :substitute/^\(.*\)$/\=empty(submatch(1)) ? '>' : printf('> _%s_', submatch(1))<enter> " or xnoremap <leader>q :substitute/^/> ...
D. Ben Knoble's user avatar
  • 25.7k
2 votes
Accepted

Best way to keybind subsequent substitutions in visual mode

To avoid the double '<,'> problem the old way is to add <C-u> at the start of the mapping: vim.api.nvim_set_keymap( "v", "<Leader>q", ":<C-u>'<...
Vivian De Smedt's user avatar
1 vote

Best way to keybind subsequent substitutions in visual mode

The point is that Vim switches from mode to mode as it reads buttons. No matter if they come from keyboard or mapping. So you only start from Visual mode. But then you get into cmdline, then into ...
Matt's user avatar
  • 20.6k
8 votes
Accepted

Why does `yW` yank until the end of the WORD, but `W` move to the next one?

It might be useful to quote :help exclusive, here: A character motion is either inclusive or exclusive. When inclusive, the start and end position of the motion are included in the operation. When ...
romainl's user avatar
  • 39.9k

Top 50 recent answers are included