Macros
Record the macro
To record a macro and save it to a register, type
the key q
followed by a letter from a
to z
that
represents the register to save the macro,
followed by all commands you want to record, and
then type the key q
again to stop the recording.
q<register><commands>q
View and load macros
Command :reg to see the content of all registers:
:reg
--- Registers ---
"" ,
"h 0r#f"xldf,A,^[p0df,$px:s/,/\t/g^Mj
"- ,
...
You can also check the specific register
:reg h
--- Registers ---
"h 0r#f"xldf,A,^[p0df,$px:s/,/\t/g^Mj
Replay macros
Press @h
where h
represents the register on
which you saved the macro.
Notice that the macro automatically moves the
cursor to the next line as required. This allows
you to repeat its execution. To repeat the macro
execution, press @@
.
Finally, you can repeat the macro on all
remaining lines by using Vim number<COMMAND>
syntax. For example, to execute the macro on the
five remaining lines, press 5@@
or 5@h
.