How do I edit multiple locations simultaneously like multiple cursors?
Answer
<C-n> to select (vim-visual-multi)
Explanation
vim-visual-multi provides VS Code-style multiple cursor support for Vim. Press <C-n> to add cursors at each occurrence of the word under cursor.
How it works
<C-n>selects the word under cursor and finds the next occurrence<C-n>again adds a cursor at the next occurrence- All cursors edit simultaneously
qskips an occurrence,Qremoves a cursor
Example
With the cursor on foo:
<C-n>selectsfooand highlights the next one<C-n>again adds a cursor at the nextfoocchanges all selected occurrences at once
Tips
- Install:
Plug 'mg979/vim-visual-multi' <C-Down>adds a cursor on the line below\\Aselects all occurrences at onceTabswitches between cursor and extend mode- Many Vim experts prefer
:s, macros, or.over multiple cursors