sequence "<Bslash>" can be used. This avoids the need to double backslashes
when using nested mappings.
*map_CTRL-C* *map-CTRL-C*
Using CTRL-C in the {lhs} is possible, but it will only work when Vim is
waiting for a key, not when Vim is busy with something. When Vim is busy
CTRL-C interrupts/breaks the command.
When using the GUI version on MS-Windows CTRL-C can be mapped to allow a Copy
command to the clipboard. Use CTRL-Break to interrupt Vim.
*map_space_in_lhs* *map-space_in_lhs*
To include a space in {lhs} precede it with a CTRL-V (type two CTRL-Vs for
each space).
*map_space_in_rhs* *map-space_in_rhs*
If you want a {rhs} that starts with a space, use "<Space>". To be fully Vi
compatible (but unreadable) don't use the |<>| notation, precede {rhs} with a
single CTRL-V (you have to type CTRL-V two times).
*map_empty_rhs* *map-empty-rhs*
You can create an empty {rhs} by typing nothing after a single CTRL-V (you
have to type CTRL-V two times). Unfortunately, you cannot do this in a vimrc
file.
|<Nop>|
An easier way to get a mapping that doesn't produce anything, is to use
"<Nop>" for the {rhs}. For example, to disable function key 8: >
:map <F8> <Nop>
:map! <F8> <Nop>
<
*map-multibyte*
It is possible to map multibyte characters, but only the whole character. You
cannot map the first byte only. This was done to prevent problems in this
scenario: >
:set encoding=latin1
:imap <M-C> foo
:set encoding=utf-8
The mapping for <M-C> is defined with the latin1 encoding, resulting in a 0xc3
byte. If you type the character á (0xe1 <M-a>) in UTF-8 encoding this is the
two bytes 0xc3 0xa1. You don't want the 0xc3 byte to be mapped then or
otherwise it would be impossible to type the á character.
*<Leader>* *mapleader*
To define a mapping which uses the "g:mapleader" variable, the special string
"<Leader>" can be used. It is replaced with the string value of
"g:mapleader". If "g:mapleader" is not set or empty, a backslash is used
instead. Example: >
map <Leader>A oanother line<Esc>
Works like: >
map \A oanother line<Esc>
But after: >
let mapleader = ","
It works like: >
map ,A oanother line<Esc>
Note that the value of "g:mapleader" is used at the moment the mapping is
defined. Changing "g:mapleader" after that has no effect for already defined
mappings.
*<LocalLeader>* *maplocalleader*
<LocalLeader> is just like <Leader>, except that it uses "maplocalleader"
instead of "mapleader". <LocalLeader> is to be used for mappings which are
local to a buffer. Example: >
:map <buffer> <LocalLeader>A oanother line<Esc>
<
In a global plugin <Leader> should be used and in a filetype plugin
<LocalLeader>. "mapleader" and "maplocalleader" can be equal. Although, if
you make them different, there is a smaller chance of mappings from global
plugins to clash with mappings for filetype plugins. For example, you could
keep "mapleader" at the default backslash, and set "maplocalleader" to an
underscore.
*map-<SID>*
In a script the special key name "<SID>" can be used to define a mapping
that's local to the script. See |<SID>| for details.
*<Plug>*
The special key name "<Plug>" can be used for an internal mapping, which is
not to be matched with any key sequence. This is useful in plugins
|using-<Plug>|.
*<MouseMove>*
The special key name "<MouseMove>" can be used to handle mouse movement. It
needs to be enabled with 'mousemoveevent'.
The |getmousepos()| function can be used to obtain the mouse position.
*<Char>* *<Char->*
To map a character by its decimal, octal or hexadecimal number the <Char>
construct can be used:
<Char-123> character 123
<Char-033> character 27
<Char-0x7f> character 127
<S-Char-114> character 114 ('r') shifted ('R')
This is useful to specify a (multibyte) character in a 'keymap' file.
Upper and lowercase differences are ignored.
*map-comments*
It is not possible to put a comment after these commands,