← All lessons

10. Make Vim Your Own With Maps

Step 2 of 6

Fundamentals of mapping with Vim

At a fundamental level, remapping with Vim is just saying “whenever these keys are typed, pretend that I typed these other keys instead”. So, the following mapping from earlier:

:inoremap ' ''<left>

is really just saying “whenever I type a ', pretend that I typed '', followed by the left arrow key”.

Mapping in different modes

You can create maps for any Vim mode — the available mapping commands are:

Let’s try this. Try defining a normal mode map and an insert mode map (:nmap/:nnoremap and :imap/:inoremap) in the editor, then try using them.

What does noremap mean?

noremap means “don’t try to recursively execute this map”. Consider the mapping from earlier:

:inoremap ' ''<left>

If we didn’t have noremap here and instead used:

:imap ' ''<left>

Then, when you type ', Vim would try to recursively look up the mapping for the ' character, causing Vim to hang. noremap squashes this behaviour. If in doubt, you probably want to be using noremap!

Loading editor…