Here is a small useful tip, which I use in my daily sysadmin work, when I have a lot of similar configuration files to alter, but my modification is to complex to be scripted with sed/awk.
The perfect example is Apache's vhost configurations in site-enabled/.
Open all files in Vim and start recording your macro (with q
) on the first buffer.
Until now I opened the next buffer, replay my macro, then opened the next buffer, replay my macro again, etc…
Pretty boring.
But I discovered recently that you can execute a command on all opened buffers, and particularly a macro. Here is the magic line:
:bufdo execute "normal @a"
Replace a with the name of your macro of course, and don't miss to :write
at the end of your macro (or add a | write
at the end of the command).