Storing Macro in VIM
* Start recording macro using q command followed by name of macro. For an
example, if macro name is a then, qa.
* Perform task to be run in macro.
* Stop recording macro using q command.
* At this point macro content is stored in register (in register q in this case).
* Paste register content using “<macro_name>p command (“ap in this case). Note
that ” is part of command.
* Now you have content of macro. You can put it in .vimrc file.
Add below line to store macro with name a.
let @a = ‘<macro content>’
For a example, for simple copy paste macro (content is yyp)
let @a = ‘yyp’
Here ‘ character defines start and end of macro content. So if ‘ character is
part of macro, you need to use ‘ character twice i.e. ”.
For an example, if macro content is yy’p then,
let @a = ‘yy”p’
Enjoy Vimming 🙂