Hacker News new | ask | show | jobs
by alpaca128 1854 days ago
The differences that actually matter are self explanatory: map is for all modes, imap for insert mode, nmap for normal mode and vmap for visual mode (& tmap for terminal mode in NeoVim). The rest can be safely ignored as far as I can tell.

Little confession: I have no idea what e.g. the difference between "nmap" and "nnoremap" is. But after years of randomly mixing them in hundreds of bindings without a noticeable difference it doesn't seem to matter. Just use map, nmap, imap and vmap, avoid duplicates and everything will be fine imho.

3 comments

You're right, for most simple use cases it doesn't matter. But I once spent an hour on a weird bug that turned out to just be some plugin applying a map that I didn't know about and that I didn't know about map expansion. So I might be biased, but I think a loose understanding is helpful.

The default behavior is to recursively expand and apply your mappings and "noremap" disables this recursion. For example if you do something like

  :map j k
  :map q j
  :noremap w j
q is expanded to k, but w is expanded to j
Thanks for this example, now I get it. It never really clicked for me when I read explanations on SO etc.
nnoremap is "non-recursive remap" since I think its possible to chain nmaps (`nmap A B, nmap B C` will map A to C)
I find that I never want "map" functionality, so I do the opposite, always use "noremap".