Vim Macro Record-and-Play
One of Vim’s superpowers is the ability to record and play macros. It’s quite simple to use - press “q”, then choose any alphabet from a to z as the register name, type your sequence of operations, and then press “q” again when done. Then, type “@” followed by the register name to play.
You can view a list of the contents of the registers with the “:reg” command and can display the contents of a specific register by appending a space followed by the register name to “:reg” command. You can also insert the commands into the current file using "<register-name>p
(including the quotation mark, excluding the angular brackets); you can also do this in insert mode with Ctrl-r Ctrl-r (yes, twice!) followed by the register name. You can make the macros persistent by using a “let @=’…..’” to the .vimrc file.
Vim sometimes automatically persists the macros between sessions (by using .viminfo)