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:
:mapfor mapping in normal mode, visual mode, select mode, and operator pending mode all at once:nmapfor mapping in normal mode:vmapfor mapping in visual mode and select mode at the same time:smapfor mapping in select mode:xmapfor mapping in visual mode:omapfor mapping in operator pending mode:imapfor mapping in insert mode:cmapfor mapping in command-line mode:tmapfor mapping in Vim’s built-in terminal
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!