What is the difference between the remap
, noremap
, nnoremap
and vnoremap
mapping commands in Vim?
The difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim
commandmappingvim
commandmappingvim
What is the difference between the remap
, noremap
, nnoremap
and vnoremap
mapping commands in Vim?
Best Answer
remap
is an option that makes mappings work recursively. By default it is on and I'd recommend you leave it that way. The rest are mapping commands, described below::map
and:noremap
are recursive and non-recursive versions of the various mapping commands. For example, if we run:Then:
j
will be mapped togg
.Q
will also be mapped togg
, becausej
will be expanded for the recursive mapping.W
will be mapped toj
(and not togg
) becausej
will not be expanded for the non-recursive mapping.Now remember that Vim is a modal editor. It has a normal mode, visual mode and other modes.
For each of these sets of mappings, there is a mapping that works in normal, visual, select and operator modes (
:map
and:noremap
), one that works in normal mode (:nmap
and:nnoremap
), one in visual mode (:vmap
and:vnoremap
) and so on.For more guidance on this, see: