Tip 69 | Append Commands to a Macro |
Sometimes we miss a vital step when we record a macro. There’s no need to re-record the whole thing from scratch. Instead, we can tack extra commands onto the end of an existing macro.
Suppose that we record this macro (borrowed from Tip 68):
Keystrokes | Buffer contents | ||||
---|---|---|---|---|---|
qa |
| ||||
0f.r)w~ |
| ||||
q |
|
Immediately after pressing q to stop recording, we realize that we should have finished by pressing j to advance to the next line.
Before we fix it, let’s inspect the contents of register a:
=> | :reg a |
<= | "a 0f.r)w~ |
If we type qa, then Vim will record our keystrokes, saving them into register a by overwriting the existing contents of that register. If we type qA, then Vim will ...
Get Practical Vim, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.