Ace-mc makes it really easy to add and remove multiple cursors using ace jump mode.
Ace-mc is available through MELPA, so installing it is as easy as:
M-x package-install RET ace-mc RET
Ace-mc comes with two commands:
ace-mc-add-multiple-cursors
ace-mc-add-single-cursor
.
Both do pretty much the same thing.
I have ace-jump-mode
bound to C-0, so I bind
ace-mc-add-multiple-cursors
to C-) and
ace-mc-add-single-cursor
to C-M-). The setup would be like
this:
(global-set-key (kbd "C-)") 'ace-mc-add-multiple-cursors)
(global-set-key (kbd "C-M-)") 'ace-mc-add-single-cursor)
ace-mc-add-multiple-cursors
prompts for a "Query Char" for the first
character of a word, much in the same way that Ace Jump does. In fact,
ace-mc-add-multiple-cursors
takes similar prefix arguments that
ace-jump-mode
does. So if you pass one C-u prefix to it, it'll
activate ace-jump-char-mode
, and with C-u C-u it'll activate
ace-jump-line-mode
.
Once you enter a query char, you'll be prompted for locations to add
multiple-cursor-mode
cursors. If a cursor is already at the
location, it'll be removed. You'll be continually prompted for more
locations to add or remove cursors until you exit out of it by pressing
Enter or Esc or anything really that's not
alphabetic.
When you have an active region, no "query char" is prompted for. Instead, you just get a list of locations that match the text in your region.
ace-mc-add-single-cursor
does the same thing as
ace-mc-add-multiple-cursors
, just without looping.