Vim advanced learning modes and button ing

Source: Internet
Author: User
Tags imap

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

:map c a

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.

    • Set Ctrl + A to.
:map <C-a> a
    • Make Alt + A correspond to
:map <A-a> a
    • CTRL + ALT + A corresponds to
:map <C-A-a> a

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:

    1. Normal Mode

That is, the most common mode. It is in this mode after Vim is entered by default.

    1. Visual Mode

This mode selects characters, rows, and columns.
In normal mode, you can press V to enter.

    1. Insert mode

The insert mode is actually in the edit input state. In normal mode, you can press I to enter.

    1. 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.

    1. 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.

    • Command combination

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

      1. Nore

Indicates non-recursion. See the Introduction below.

      1. N

Effective in Normal Mode

      1. V

Indicates that it takes effect in visual mode.

      1. I

Indicates that it takes effect in insert mode.

      1. C

In command line mode.

    • Recursive Mapping

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.

:map a b:map c a

The effect on C is equivalent

:map c b

The default map is recursive. If the prefix [nore], such as noremap, indicates that the map is non-recursive.

    • Unmap

The unmap is followed by a combination of buttons to delete the ing.

:unmap c

In map effective mode, C is no longer mapped to.

Similarly, unmap can be prefixed to indicate the affected mode.

    • Mapclear

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

  1. Create a mapping in Command Line Mode
     nmap b a 
  2. In normal mode, press B to enter the insert mode and enter some characters at will.
  3. Create a mapping in Command Line Mode
     vmap b d 
  4. In normal mode, press V to enter the visual mode, select a whole row, and press B to delete the entire row.
  5. Create a mapping in Command Line Mode
     imap b a 
  6. Now try to input a character "B" to the file being edited: P
  7. Create a mapping in Command Line Mode
     cmap b c 
  8. 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

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.