vim macros - how to create vim macros

vi/vim FAQ: Can you provide some examples of how to create vim macros?

Here's a quick example of how to define macros that you can use in the vim editor (or vi editor). As you can tell by looking at them, I use these particular vim macros when editing HTML files.

Define vim macros with the vim map command

Step 1 in the process or creating vim macros is to edit the vi/vim startup file in your home directory. On Unix, Linux, and Mac OS X systems, this file is named .vimrc.

So, move to your home directory like this:

cd

Then edit your vimrc configuration file like this:

vi .vimrc

Next, insert the following vim macro command lines (vim map commands) into your .vimrc file. Note that wherever you see the ^M character below, you actually need to type the following key sequence: [Ctrl]v [Ctrl]m