Last Updated: February 25, 2016
·
1.038K
· christopherdebeer

save and share vim macros

To define a macro launched by CTRL+G for example, add the following line to your ~/.vimrc :

map <C-G> {{MACROTEXT}}

To get the text you'll put in place of {{MACROTEXT}} do the following:

Record a macro into a register ("a"), by typing qa ... do your thing ie: the steps you want to record, and then press q again to stop recording.

Type "ap and it should paste the macro you just recorded as text, which is what you use in place of {{MACROTEXT}} in your ~/.vimrc file.

An example:

map <C-G> vaw:s/_/(underscore)/g^M