Five mappings exist.
-For normal mode: when you enter a command.
-For visual mode: When the visible area is highlighted and a command is entered.
-Used for operator waiting mode: The operator is waiting ("d", "y", "c", etc ).
See: | omap-info |.
-For insert mode: it is also for replace mode.
? For command line mode: Enter the ":" or "/" command.
The following table shows the mode code of map binding. Now let's take a look at it. After reading it, we will see the pattern code.
Font mode ~
<Space> common, visualized, selection, and operator waiting
N normal
V visualization and selection
S Selection
X Visualization
O operator waiting
! Insert and command line
I insert
L ": lmap" ing of insert, command line, and Lang-Arg Mode
C command line
I will mainly explain the two binding commands under "n (normal mode)". After reading the commands, I will understand the commands in other modes.
The ing commands for common modes mainly include:
1.: map
[Syntax]: map {lhs} {rhs} | mapmode-nvo | *: map *
1.1 mode of action: n, v, o (common, visual, and selection, operator waiting)
1.2 command format:
: Map {lhs} {rhs}
Meaning: In the map mode, the key series {lhs} is mapped to {rhs}, and {rhs} can be mapped for scanning, that is, recursive ing.
1.3 example:
: Map td: tabnew. <cr>
Meaning: in its effective mode (normal, visualized, and operator), the input td is equivalent to the input tabnew. <cr>. In normal mode, enter tabnew. <cr> to open the current directory.
If you re-define the binding: map ts td, it means that in the effective mode, the input ts is equivalent to td, that is, to open the current directory. However, if there is no special need, recursive ing is generally not recommended.
2.: noremap
: Compared with the: map command, the mode and command format are the same, but the {rhs} ing scan is not allowed, that is, the ing defined by {lhs} is the key sequence of {rhs} and will not re-interpret and scan the {rhs} key sequence. It is generally used to redefine a command. If: map does not require recursive ing, we recommend that you use: noremap
For example:
: Noremap ts td
In this mode, the input ts is the input td, but unlike map, the td will not be further scanned. Although td has been defined before, but does not scan td again
3.: unmap
: Unmap is the {lhs} bound to the unmap. It works in the same mode. Command Format: unmap {lhs }.
For example:
: Unmap td
Cancel the binding of td in the action mode. For example, if td was previously bound to tabnew. <cr>, the binding disappears.
4.: mapclear
: When mapclear is used, cancel all: map bound. Use it with caution!
5.: nmap
: Nmap is the normal mode board of map. That is to say, the bound key only applies to the normal mode.
For example:
: Nmap td: tabnew. <cr> and: map td: tabnew. <cr> are equivalent in normal mode.
6.: nnoremap
: The relationship between nnorempa and: nmap is the same as that between: noremap and: map, except that nmap is non-recursive.
7.: nunmap
The relationship between: nunmap and: nmap is the same as that between: unmap and: map. Cancel: nmap binding.
8.: nmapclear
: Nmapclear cancels all: map binding. Use it with caution!
After reading the above, we can find a rule. The first four are a group, the last four are a group, and the last one is n more than the previous one, that is, it only applies to the normal mode. * Nore * in each group is its non-recursive version, * un * Is to unbind a <lhs> binding, and the clear suffix is to unbind all bindings. After finding this rule, go to the previous schema code table. You can roughly guess what vmap, xmap, smap, and omap mean, and the corresponding nore version, un version, and clear version.
In addition:
A special character may be displayed before {rhs:
* Indicates that it cannot be remapped.
& Indicates that only local Mappings of scripts can be remapped.
@ Indicates the local ing of the buffer.
At this point, you can take a long breath, because the relevant commands have been understood, and it does not matter, you can at any time: help map. But don't worry. There are more options to map in the future.
Key table | key-notation |
<K0>-<k9> keypad 0 to 9 * keypad-0 ** keypad-9 *
<S-...> Shift + key * shift ** <S -*
<C-...> Control + key * control ** ctrl ** <C -*
<M-...> Alt + key or meta + key * meta ** alt ** <M -*
<A-...> same as <m-...> * <-*
<T_xx> the "xx" Entry key in termcap
Special parameters:
1. <buffer>
2. <silent>
3. <special>
4. <script>
5. <expr>
6. <unique>
They must be mapped to the back of the command, before any other parameter.
<Buffer> If the first parameter of these ing commands is <buffer>, the ing is limited to the current buffer (that is, the file you are editing at this time. For example:
: Map <buffer>, w/a <CR>
It defines key binding in the current buffer, and ", w" searches for character a in the current buffer. You can also define in other buffers:
: Map <buffer>, w/B <CR>
For example, if I often open multiple tags (tabedit) and want to define the ", w" Key Binding in each tag, you only need to define them in each tab, its scope is only in the respective labels. The <buffer> parameter must also be added to the Key Binding to clear the buffer, for example:
: Unmap <buffer>, w
: Mapclear <buffer>
<Silent> indicates that the command line ECHO is not performed when the key binding is executed. For example:
: Map <silent>, w/abcd <CR>
When you enter w to search for abcd, the command line will not display/abcd. If no <silent> parameter is displayed
<Special> it is generally used to define special keys to avoid side effects. For example:
: Map <special> <F12>/Header <CR>
<Unique> this command is generally used to define a new key ing or abbreviated command and check whether the key has been mapped. If the ing or abbreviation already exists, the command will fail.
<Expr>. If the first parameter of the new ing is defined as <expr>, the parameter is calculated as an expression and the actual use of the result is <rhs>, for example:
: Inoremap <expr>. InsertDot ()
This can be used to check the text before the cursor and enable omni completion under certain conditions.
Example:
Let counter = 0
Inoremap <expr> <C-L> ListItem ()
Inoremap <expr> <C-R> ListReset ()
Func ListItem ()
Let g: counter + = 1
Return g: counter .'.'
Endfunc
Func ListReset ()
Let g: counter = 0
Return''
Endfunc
In insert mode, the CTRL-L inserts the list number of the order and returns; the CTRL-R resets the list number to 0 and returns NULL.
<Leader> mapleader
The mapleader variable is effective for all map commands. It is used to replace the parameter <leader> with the value of the mapleader variable, for example:
: Map <Leader> A oanother line <Esc>
If the mapleader variable is not set, use the default backslash instead. Therefore, this ing is equivalent:
: Map \ A oanother line <Esc>
When the \ A key is input, the next line enters another line and returns to normal mode.
If the mapleader variable is set, for example:
Let mapleader = ","
This is equivalent:
: Map, A oanother line <Esc>
<LocalLeader> maplocalleader
<LocalLeader> is similar to <Leader>, but it only acts on the buffer zone.
Therefore, it is best to separate mapleader and maplocalleader without conflict.
Author "venus585625"