Possible Duplicate:
Saving vim macros
I always used macros across the lines and they’re a lifesaver. But lately, I’ve started using them to do some more complicated file manipulations, and I would like to record them to a function, or use them in some way across Vim sessions so that I don’t have to re-record them every time I quit Vim.
What would be the easiest way to go about that?
Vim macros are actually just text saved in registers, and since the registers are saved across sessions – your macros are automatically saved.
However, the way I see it, the whole idea behind macros is that you can create them quickly, use them, and then discard them. If you want something more permanent, you should take the effort and write a custom command or a keymap – and if that’s a complex macro, you should write a function for it in proper vimscript(or whatever other scripting language vim supports).
If it’s something you are going to use alot, you want to be able to make changes and fixes to it now and then – but this is very hard to do in macros, because they are text strings representing key strokes – not commands.