Vim Mass Edit Trick
For all you VIM’ers out there (and possibly VI’ers) here’s a neat trick: if you find yourself performing the same series of edits over blocks of text (e.g. changing the formatting a series of functions) you can record the command series as a macro.
To start a macro, enter command mode (i.e. press ESC) and then press ‘q#’, where ‘#’ is a letter (technically, ‘#’ represents a register in VIM, which can be used for all sorts of interesting things, but for our purposes it just stores the macro).
Then type your series of commands. It will record all commands: movements, insertions, deletions, and all that.
End the macro by going back to command mode and press ‘q’ again. Your macro is now stored into the ‘#’ register you chose earlier.
From now on you can apply the macro by typing ‘@#’, where ‘#’ is the register you saved it in previously.
For example, I type the following to make a macro that deletes a line below the current line:
ESC // enter command mode qa // start macro in register 'a' j // move down a line dd // delete current line k // move up a line q // end macroThen I run use by typing:
@a // run macro in register 'a'
Obviously, the above example is pointless, but it gives you idea of the how it works.