4

I just switch from Sublime text to MacVim. One useful shortcut I loved in sublime is cmd+D which adds the next occurrence of the current word to the selection. Is there any way I can get the equivalent in VIM?

Many thanks

Spearfisher
  • 8,445
  • 19
  • 70
  • 124
  • No quick and clean way to do this in stock vim. I switched to using vim plugin within vscode and this works well for me to solve this issue: https://stackoverflow.com/a/76358638/2826818 – alexbhandari May 29 '23 at 16:18

1 Answers1

3

Not natively, but you can look if the vim-multiple-cursors has this feature.

Here is a related stackoverflow question: Multiple selections in VIM.

If you know that you want to select and modify all occurrences of the current word under the cursor, press * to select it and in command-mode execute:

%s//replacement

Otherwise, if you don't want the replacement to happen in the whole file, select the word with *, select a few lines in visual mode and in command-mode execute:

s//replacement
Community
  • 1
  • 1
mrucci
  • 4,342
  • 3
  • 33
  • 35