Recording macros is a way to make some repetitive tasks automatically in VIM.
Macros use one of the VIM registers to be storage, each register is identified by a letter
To start a Macro, in Normal Mode, press:
qs starts the macro in the register
At this point you will see in VIM bottom line
recording @q, this means everything you type now will be registered in the macro.
To stop recording the macro, press
<ESC> to go back to NORMAL mode, and
q to quit the macro.
To execute the macro you record, press
@ and the register
The complete process looks like this:
...-> the series of commands you want to record
<ESC>q-> go back to NORMAL mode and quit the macro record
@q-> execute the macro, starting from the line you current are
@@-> execute the macro again
You can find more information about macros in the VIM Tips Wiki: