views:

306

answers:

2

Question says it all.

+13  A: 

remap is an option that makes mappings work recursively. By default it is on and I'd recommend you leave it that way.

There's then a set of mapping commands like :map and :noremap, which are recursive and non-recursive versions of the various mapping commands.

In this example, :map is the recursive one and :noremap is the non-recursive one. What that means is that if you do:

:map j gg
:map Q j
:noremap W j

j will be mapped to gg, Q will be mapped to gg (as the j will be expanded for the recursive mapping) and W will be mapped to j (as the j will not be expanded for the non-recursive mapping).

For each of these sets (recursive and non-recursive), there is a mapping that works in every mode (:map and :noremap are recursive and non-recursive respectively), one that works in normal mode (:nmap and :nnoremap), one in visual mode (:vmap and :vnoremap) etc.

For more guidance on this, see:

:help :map
:help :noremap
:help recursive_mapping
:help :map-modes
Al
Thanks for your answer! Also, when is recursive used, and when is non-recursive used?
Chetan
@Chetan: It depends what you want to achieve. I tend to use non-recursive more often, but if you've defined a relatively complicated mapping using non-recursive and what another mapping that does everything the first mapping does and more, it can be easier to use a recursive mapping that includes the original one rather than retyping the whole of the non-recursive one again (particularly if you then need to tweak the original one).
Al
+2  A: 

caution, vnoremap and vmap work in visual AND select mode. To have a mapping only in visual mode, use xmap and xnoremap.

Benoit