Emacs Elements has a very short video on a relatively unknown but extraordinarily useful command: iedit. It does basically the same job as multiple cursors but is builtin and a bit simpler. It’s less powerful than multiple cursors but is usually more than powerful enough for the job at hand. I use it all the time, usually in preference to commands like query-replace
and its siblings.
The video is less than two minutes long so it doesn’t cover many of the nuances involved with iedit. The most important such nuance is what text is selected for editing. If you just place the cursor on some text, the selected text is basically what’s returned by thing-at-point
. I often find that that is not what I want so I highlight the word (or extended text) that I’m interested in instead. Then, that text is selected as if by a substring match. On the other hand, that may not always do the right thing either so you should be familiar with both methods. You can also edit the regular expression by hand to get exactly what you want.
Another obscure but useful nuance is restricting the range of selection to the current function. You do that by by specifying a prefix of 0 to the command. There’s a fairly long description of how the command works in its document string so ts worthwhile calling Help for iedit to get the full story.
As I said, the video is very short—only 1 minute, 55 seconds—so it’s easy to fit in. Take a look at the video to get the general idea but you should definitely read the Doc entry too.