October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 93 | Repeat the Previous Substitute Command |
At times, we might have to amend the range of a substitute command. We might have made a mistake on our first try, or maybe we just want to rerun the command exactly but on a different buffer. A couple of shortcuts make it easy to repeat the substitute command.
Suppose that we’ve just executed this command, which acts upon the current line:
| => | :s/target/replacement/g |
We realize our mistake at once: we should have prepended %. No harm done. We can repeat the command across the entire file just by pressing g& (see g&ⓘ), which is equivalent to running the following:
| => | :%s//~/& |
This longhand command spells out the following instruction: ...