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
Written by Christopher de Beer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#