Saving ViM Macros

March 11, 2009 at 09:32 AM | categories: tips, vim | View Comments

I use ViM macros (aka complex-repeat) all the time. Occasionally, I find that it would be nice to reuse one of my macros across editing sessions. Turns out it's pretty easy to save the macro. Just add a line like the following to a file that gets sourced when your file is opened by ViM (This example is from ~/.vim/ftplugin/rst.vim).

let @h = "yypVr"

Now, whenever I open a ReStructured Text file, I can hit @h and my macro will run.

blog comments powered by Disqus