What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?

Viewed 279358

What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?

4 Answers

I will explain mapping commands simply.

First, we have two general mapping commands:

  • map - works recursively in normal, visual, select and operator pending modes.
  • map! - works recursively in insert and command-line modes.

The non-recursive variations of these commands are:

  • noremap - works non-recursively in normal, visual, select and operator pending modes.
  • noremap! - works non-recursively in insert and command-line modes.

Then, we have mode-specific commands:

  • nmap - works recursively in normal mode.
  • imap - works recursively in insert mode.
  • vmap - works recursively in visual and select modes.
  • xmap - works recursively in visual mode.
  • smap - works recursively in select mode.
  • cmap - works recursively in command-line mode.
  • omap - works recursively in operator pending mode.

And their non-recursive variations:

  • nnoremap - works non-recursively in normal mode.
  • inoremap - works non-recursively in insert mode.
  • vnoremap - works non-recursively in visual and select modes.
  • xnoremap - works non-recursively in visual mode.
  • snoremap - works non-recursively in select mode.
  • cnoremap - works non-recursively in command-line mode.
  • onoremap - works non-recursively in operator pending mode.

Finally, remap is a boolean option that allows for mappings to work recursively. It is worth mentioning that you should always keep this option at the default on.

Related