11.Macros
65. Record and Execute a Macro
Mcross allow us to record a sequence of changes and then paly them back. This tip shows how.
Capture a Sequence of Commands by Recording a Macro
q{register}
start recordingqa
start recording into register aq
stop recording:reg a
inspect the contents of register a
Play Back a Sequence of Commands by Executing a Macro
@{register}
executes the contents of the specified register@a
executes the contents of register a@@
repeats the macro that was invoked most recently10@a
executes 10 times
66. Normalize, Strike, Abort
Executing a macro can sometimes produce unexpected results, but we can achieve better consistency if we follow a handful of best practices.
Normalize the Cursor Position
Strike Your Target with a Repeatable Motion
Abort When a Motion Fails
67. Play Back with a Count
68. Repeat a Change on Continuous Lines
69. Append Commands to a Macro
Sometimes we miss a vital step when we record a macro. There's no need to re-recording the whole thing from scratch. Instead, we can tack extra commands onto the end of an existing macro.