Create multiple cursors to edit in parallel multiple lines of text in the current buffer.
Multiple cursors is especially useful where lines are not entirely identical, i.e. they have the same basic form but have different values
Multiple cursors allows you to call all Emacs named functions and have the results output to each cursor you have created.
Hint::iedit or multiple cursorsλ︎
iedit is excellent for all kinds of search and replace actions where the text to change is the same. iedit finds all matches in a buffer or the scope created by narrowing.
Where text lines do not match but have a similar form, multiple cursors allow for more irregular changes
g r shows the menu for multiple cursors
g r j adds a cursor to the next line
24 g r j will create multiple cursors for 24 consecutive lines.
g r I adds cursors to visual selection lines,
S-v and arrow keys, or
v 20 j to select the next 24 lines
Hint::Using Narrowing to constrain where cursors are createdλ︎
SPC nmenu allows you to narrow the view on the current buffer
SPC n fnarrows to the current function definition
SPC n rnarrows to a selected range of text
See the section on Spacemacs - Narrowing
The most commonly used key bindings for multiple cursors
||creates a new cursor on the line below (adhoc changes)|
||create new cursor on the line above (adhoc changes)|
||create new cursor on selected lines|
||create cursors on all matching text (under cursor or region of selected text)|
||make a cursor at point and go to the next match|
||go to the next match without creating a cursor at current point|
||make a cursor at point and go to the previous match|
||go to the previous match without creating a cursor at current point|
||when you have finished to remove all cursors and leave just one cursor.|
g r shows the full menu
TODO::Add video of most commonly used featuresλ︎
- Only named commands can be executed by multiple cursors.
- There could be a performance penalty when there are too many cursors (30+).
- Paste will not work when the Spacemacs paste transient state is enabled. This is due to the fact that evil-paste-pop and evil-paste-pop-next commands are not supported.
- evil-repeat works only for some commands. In particular it doesn’t work for delete. It will also interfere with the cursor positions during an undo or redo operation.
- multiple cursors layer - Spacemacs develop documentation
- evil-mc - default backend for multiple cursors layer
- evil-multiedit - used in Doom Emacs