The first step to creating a macro is to plan the individual steps that will be recorded. After the
steps have been planned, it is time to record the macro.
To start recording a macro, simply type q followed by the name of the named register
that you would like to store the macro in. After that, proceed through the sequence of steps that
you would like to record, then when you are done simply type q again to stop recording and save
the macro in the register.
Lets walk through an example. Suppose we want to create a macro that wraps each line of text in
HTML <p> tags. We can approach this in a few different ways, but for this example we will
follow these steps:
Start recording the macro
Insert a line below the current line and add the closing tag
Insert a line above the current line and add the opening tag
Join all three lines together
Stop recording the macro
Now, let's break each of these steps down into the sequence of keystrokes required to
implement it, and record them. The keystrokes for Step 1 are:
Press q to begin recording the macro, then a to specify which register to store it in
Press o to insert a line below the current line and enter insert mode