I have been using an Emacs package called multiple-cursors for some time now. I'm not even a power user of it and I benefit from quicker edits.
Take the following example:
if (valueA != null) {
map.set("a", valueA);
}
if (valueB != null) {
map.set("b", valueB);
}
I frequently use the wrong method name. It's map.put
, not map.set
in this example.
Now I could go to each occurrence and change it. I could highlight the region and do M-x replace-string
or M-x query-replace
but I like to highlight the map.set
and do M-x mc/mark-next-like-this
I even bind it to C->
for quick access.
(mc/mark-next-like-this ARG)
Find and mark the next part of the buffer matching the currently active region
If no region is active add a cursor on the next line
With negative ARG, delete the last one instead.
With zero ARG, skip the last one and mark next.
There are other fun tricks too like mc-insert-letters
It inserts consecutive increasing letters. mc-insert-numbers
inserts, you guessed it, consecutive increasing numbers. Think of all the times you've had to re-number enum values or other lists of numbers. Way easier now!
(mc/insert-letters ARG)
Insert increasing letters for each cursor, starting at 0 or ARG.
Where letter[0]=a letter[2]=c letter[26]=aa