A Quick VIM Key Mapping Howto.

     Setting up key maps is easy to do in VIM. Say, for example, you wanted to create a key map that allows you to insert, "I have an angry caribou.", into the file you are editing, bound to "Shift + F5". Fire up vim, hit : and type

map thekeyorkeycombinationyouwanttouse i I have an angry caribou.

Which will actually look like this, if you use Shift + F5:

:map <S-F5> i I have an angry caribou.

Then hit enter.

What did you just do? I'll reprint the command, with explanations surrounded by ().

The actual command:
:map <S-F5> i I have an angry caribou

What it means:

:map (the command to create your key map macro)
<S-F5> (the actual key strokes I want for my key map, generated automagically by VIM, when I depress the keys.)
i (Insert command in vim. Could be "a" if you want to append or any other vim command.)
I have an angry caribou (text I want inserted by the previous "i" command, when I hit my mapped key strokes)

Let's test. If you have done exactly what I have demonstrated above, type the key combination in regular mode and it should insert the aforementioned message of "I have an angry caribou", in your file and keep you in edit mode.

But, let's say you don't want to be in edit mode, after the text was inserted, and prefer to return to regular mode afterwards, you can add <ESC> to the above command and it will return you to regular mode. Example:

:map <S-F5> i I have an angry caribou <ESC>

To see what you have mapped out, type


It'll show you what key maps you have already.

To get rid of unwanted key maps in VIM:

:unmap yourkeycombination

Try this out the above process, a few times, and I am sure you'll grok VIM key maps quickly.

     If you still find VIM perplexing, try out this cheat sheet. It may assuage your pain. I'm using Debian Etch and this shouldn't matter, but I'll fall back on YMMV.