Vim Map Nmap

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/taoshengyang/article/details/6319106

There are five types of mappings present
-For Normal mode: When the command is entered.
-For Visual mode: visible area highlighting and entering commands.
-For operator wait mode: operator wait (after "D", "Y", "C", etc.).
See below: |omap-info|.
-For Insert mode: Also used for replacement mode.
? For command line mode: When the ":" or "/" command is entered.

The following table is the corresponding pattern designator in the map bindings. Now look at the first, and then go back to see the pattern code will understand.
Character Mode ~
<Space> general, visual, selection, and operator waits
n Normal
V Visual and selection
S selection
X Visual
o operator wait
! Insert and command line
I insert
L ": Lmap" mappings for INSERT, command line, and Lang-arg modes
C command line


I mainly explain the "n (normal mode)" under the two binding commands, and so on after reading the corresponding understanding of other modes of command.
The main mapping commands for normal mode are:
1.: Map
[Syntax]: map {LHS} {RHS} |mapmode-nvo| *:map*
1.1 Mode of Action: N, V, O (normal, visible and selectable, operator wait)
1.2 Command format:
: Map {LHS} {RHS}
Meaning: Mapping the key series {LHS} to {RHS},{RHS} in the mode of Map action allows for map scanning, that is, recursive mapping.
1.3 Examples:
: Map Td:tabnew .<cr>
Meaning: In its mode of action (normal, visible, operator), input TD equivalent to input: tabnew. <cr>. In normal mode, enter: Tabnew. <cr> is to open the current directory
If the binding is defined again: Map TS TD means that the input TS is equivalent to TD in its mode of action, that is, open the current directory. However, recursive mapping is generally not recommended if there is no special need.

2.: Noremap
: Moremap and: The map command is relative, the action mode and the command format are the same, except that the mapping of {RHS} is not allowed to scan, that is {LHS} after the definition of the map is {RHS} key sequence, no longer the {RHS} key sequence to re-interpret the scan. It is generally used to redefine a command, of course, if: Map does not require recursive mapping, it is recommended to try: Noremap
Like what:
: Noremap TS TD
It means that in its mode of action, input TS is input TD, but and: map is different, at this time TD will not do further scanning interpretation. Although TD has been defined before, it does not scan the TD again

3.: unmap
: Unmap is the corresponding cancel: map bound {LHS}, with the same mode of action, command format: unmap {LHS}.
For example:
: Unmap TD
is to cancel the binding of TD in its mode of action, such as before TD was bound to: Tabnew. <cr> At this point, the binding disappears.
4.: mapclear
: Mapclear when the corresponding cancellation of all: Map binding, use with caution!

5.: Nmap
: Nmap is: Map's normal mode board, that is, its bound keys are only used in normal mode.
For example:
: Nmap td:tabnew .<cr> and: Map td:tabnew .<cr> equivalent in normal mode
6.: Nnoremap
: Nnorempa and: Nmap relations and: Noremap and: Map of the same relationship, just: nmap non-recursive version
7.: Nunmap
: Nunmap and: Nmap's relationship with: Unmap and: Map of the same relationship, Cancel: Nmap binding.
8.: nmapclear
: Nmapclear is the corresponding cancellation of all: Map binding, use with caution!

After reading the above, you should be able to find a rule, the first 4 is a group, the last 4 when a group, the latter group of more than the previous group of N refers only to the normal mode. where each group within the *nore* is its corresponding non-recursive version, *un* is unbinding a <lhs> binding, and the clear suffix is to cancel all bindings. Found this rule, and then turn to the previous Pattern Code table, you can generally guess Vmap, xMAP, SMAP, omap what the meaning of it, as well as the corresponding Nore version, UN version, clear version.

Other than that:
A special character may be displayed before {RHS}:
* Indicates that it is not remap
& indicates that script-only local mappings can be remapped
@ Represents a local mapping of a buffer

In this step you can easily take a long breath, because the relevant commands have been understood, can not remember it's okay, at any time: Help map a bit. But don't worry, there are more options behind the map to conquer.

Key table |key-notation|
<k0>-<k9> Numpad 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-... > <m-... > *<a-*
<t_xx> "XX" entry key in Termcap

Special parameters:
1. <buffer>
2. <silent>
3. <special>
4. <script>
5. <expr>
6. <unique>
They must map behind the command, before any other parameters.

<buffer> if the first parameter of these mapping commands is &LT;BUFFER&GT, the mapping will be confined to the current buffer (that is, the file you are editing at this time). Like what:
: Map <buffer>,w/a<cr>
It means to define a key binding in the current buffer, ", w" will look for the character a in the current buffer. You can also define in other buffers:
: Map <buffer>,w/b<cr>
For example, I often open multiple tags (: tabedit), and want to define ", W" key bindings in their respective tags, so you can define them separately in each tab, and their scopes are only in their own tags. Also to clear the key bindings of these buffers to add <buffer> parameters, such as:
: Unmap <buffer>, W
: Mapclear <buffer>

<silent> refers to the execution of key bindings that are not echoed on the command line, such as:
: Map <silent>,w/abcd<cr>
When you enter, W finds ABCD,/ABCD is not displayed on the command line, and if no <silent> parameters are displayed

<special> is generally used to define special keys for the occasion of fear of side effects. Like what:
: Map <special> <F12>/header<cr>

<unique> is typically used to define a new key mapping or abbreviation command while checking if the key is already mapped, and if the mapping or abbreviation already exists, the command fails

<expr>. If the first parameter defining the new mapping is &LT;EXPR&GT, then the argument is evaluated as an expression and the result uses the <rhs&gt that is actually used, for example:
: Inoremap <expr>. Insertdot ()
This can be used to check the text before the cursor and to start the omni complement under certain conditions.
An 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, CTRL-L inserts the order of the list number and returns the Ctrl-r reset list number to 0, and returns NULL.


<leader>mapleader
The Mapleader variable works for all map map commands, and it is useful to replace the parameter <leader> with the value of the Mapleader variable, such as:
: Map <leader>a Oanother line<esc>
If the Mapleader variable is not set, it is replaced with the default backslash, so this mapping is equivalent to:
: map/a oanother line<esc>
When you enter the/a key, enter another line in the next row and return to normal mode.
If a Mapleader variable is set, for example:
Let Mapleader = ","
Then it is equivalent to:
: Map, A Oanother line<esc>

<localleader>maplocalleader
<LocalLeader> is similar to <Leader>, except that it is only used for buffers.
Therefore, when setting Mapleader and Maplocalleader, it is best to distinguish between regions and avoid conflicts.

The main parts of the map are already mentioned, and there are a number of specific mapping-related things to see: Help map

Vim map Nmap (RPM)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.