Map is an important reason for Vim's power. You can customize various shortcut keys and use them with ease.
The most basic map usage in VIM is
C is mapped to a. When map takes effect, pressing C is equivalent to pressing.
Of course, commonly used Ctrl, shift, and ALT are also supported.
- Make Alt + A correspond to
- CTRL + ALT + A corresponds to
Now, we can do a lot of things.
However, the map command is far more than this. In different modes, the same set of buttons can be mapped to different combinations.
Vim has many modes, but it is generally mentioned as follows:
- Normal Mode
That is, the most common mode. It is in this mode after Vim is entered by default.
- Visual Mode
This mode selects characters, rows, and columns.
In normal mode, you can press V to enter.
- Insert mode
The insert mode is actually in the edit input state. In normal mode, you can press I to enter.
- Select Mode
The common mode in gvim can be called the select mode. When you drag the selected area with the mouse, the selection mode is displayed.
Different from the visual mode, in this mode, after the highlighted area is selected, press any button to directly enter and replace the selected text.
The editing effect is the same as that of the selected editor in windows. In normal mode, you can press GH to enter.
- Command-line/ex Mode
It is called the command line mode and the ex mode. The two are slightly different. In normal mode, press colon (:) to Enter command-line mode. You can enter various commands,
Use various powerful functions of vim. In normal mode, Q is used to enter the ex mode, which is actually the command-line mode with multiple lines.
There are several basic concepts for map.
Like other commands in Vim, the command name usually consists of several segments. The prefix is used as the modifier of the command itself to fine-tune the effect of the command.
For map, there may be several prefixes
Indicates non-recursion. See the Introduction below.
Effective in Normal Mode
Indicates that it takes effect in visual mode.
Indicates that it takes effect in insert mode.
In command line mode.
Recursive ing. In fact, it is well understood that if key A is mapped to B, and C is mapped to a, and if the ing is recursive, C is mapped to B.
The effect on C is equivalent
The default map is recursive. If the prefix [nore], such as noremap, indicates that the map is non-recursive.
The unmap is followed by a combination of buttons to delete the ing.
In map effective mode, C is no longer mapped to.
Similarly, unmap can be prefixed to indicate the affected mode.
Mapclear directly clears all mappings in related mode.
Similarly, mapclear can be prefixed to indicate the affected mode.
Some commonly used map commands are listed here. The default map command affects normal mode and visual mode.
: Map: noremap: unmap: mapclear
: NMAP: nnoremap: nunmap: nmapclear
: Vmap: vnoremap: vunmap: vmapclear
: IMAP: inoremap: iunmap: imapclear
: Cmap: cnoremap: cunmap: cmapclear
You can try these commands
- Create a mapping in Command Line Mode
nmap b a
- In normal mode, press B to enter the insert mode and enter some characters at will.
- Create a mapping in Command Line Mode
vmap b d
- In normal mode, press V to enter the visual mode, select a whole row, and press B to delete the entire row.
- Create a mapping in Command Line Mode
imap b a
- Now try to input a character "B" to the file being edited: P
- Create a mapping in Command Line Mode
cmap b c
- In command line mode, if you press B,
Now, you have made a mess with the vim buttons. Try to clear these mappings with unmap and mapclear. :]
From: http://haoxiang.org/2011/09/vim-modes-and-mappin/
Vim advanced learning modes and button ing