October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 65 | Record and Execute a Macro |
Macros allow us to record a sequence of changes and then play them back. This tip shows how.
Many repetitive tasks involve making multiple changes. If we want to automate these, we can record a macro and then execute it.
The q key functions both as the “record” button and the “stop” button. To begin recording our keystrokes, we type q{register}, giving the address of the register where we want to save the macro. We can tell that we’ve done it right if the word “recording” appears in the status line. Every command that we execute will be captured, right up until we press q again to stop recording.
Let’s see this in action:
| Keystrokes | Buffer Contents |
|---|---|
qa |