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:
- :map for mapping in normal mode, visual mode, select mode, and operator pending mode all at once
- :nmap for mapping in normal mode
- :vmap for mapping in visual mode and select mode at the same time
- :smap for mapping in select mode
- :xmap for mapping in visual mode
- :omap for mapping in operator pending mode
- :imap for mapping in insert mode
- :cmap for mapping in command-line mode
- :tmap for mapping in Vim’s built-in terminal
Work through the checklist below: define the normal mode map and the insert mode map suggested in the demo, and try each one out right after you create it.
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 behavior. If in doubt, you probably want to be using noremap!