Macro is like a magic.
All the while, I’m a fan of Vim editor. In fact, this whole blog is edited with Vim editor (manually).
Macros in VIM#
Today I learn my first macro in Vim editor.
Here are the steps to create a macro, to repeat on editing the line, and apply it.
Creating Macro#
To record a macro (from command mode):
Press
qto start a macro.Press
hto register for macro.Goto insert mode and edit a line as usual.
- (Goto position of the first line)
- press
ito switch to insert mode - press
"for open quote - press
ESCto switch back to command mode - press
ato append to the end of line position and switch to insert mode - press
"and,for closing quote with comma - press
ESCto switch back to command mode - press
ENTERto goto next line (at first position)
Press
qto stop the macro.
Apply The Macro#
To simply apply the recorded macro to a line, press @h.
To apply the macro to multiple lines, press 5@h.
Demo (YT Shorts)#
Thank you typecraft for the excellent tip!
