Macro is record and play feature. When this is combined with Vim commands it becomes really powerful combination. In this section, we will discuss following items −
To start recording press q followed by any lower case letter as a macro name. For instance in below example I have used “a” as a macro name
In this step you can perform any Vim actions like: cut, copy, delete, replace and so on.You can see these actions by executing following command −
:registers
For instance, below command shows that yank and delete actions were performed −
Once you are done with actions, press q again to stop recording. Now recording mode will disappear as shown below −
To play execute below command −
@{macro-name}
For instance to execute macro “a”, execute below command −
@a
To play same macro multiple times use numbers with it. For instance, to execute same macro 10 times execute following command −
10@a