Several modes of "vim" switching

Source: Internet
Author: User

Many beginners start vim, do not know how to enter characters: Press the half-day letter, the result screen is still empty.

Vim is not the same as Notepad or word, and it is in normal mode when you enter text without opening it.

There are 4 modes of VIM:

    • Normal Mode (Normal-mode)
    • Insert mode (Insert-mode)
    • Command mode (Command-mode)
    • Visual Mode (Visual-mode)

Note : the arrow keys (up and down) can jump to and from the vim screen. Now I know this is right
It is useful to experience the following patterns. However, moving through the directional arrows is a stupid way ... talked about normal.
Mode when it comes to better methods (I won't tell you right now. h,j,k,l keys correspond to left, bottom, Upper, right: D)

Normal mode

Normal mode is generally used to browse files, but also include some copy, paste, delete and other operations. When you hit the key,
The general key/key combination will be treated as a function key without typing the corresponding character.

In this mode, we may jump through the keyboard in the text to jump, jumping range from small to large is the character,
Words, lines, sentences, paragraphs, and screens.

The default is in normal mode when Vim is started. No matter what mode you are in, press the <Esc> button (sometimes you need to press twice)
will go into normal mode.

Insert mode

Pressing I, I, a, a etc in normal mode (described later in this series) will enter insert mode.
Now just remember to press the I key to insert mode. In insert mode, the corresponding character is written when the key is clicked.

Command mode

In normal mode, pressing the: (colon) key will enter the command mode. In command mode, you can perform
Some input and execute some of the instructions provided by VIM or plug-ins, just like in the shell. These directives include
Set the environment, file operations, invoke a feature, and so on.

Visual mode

In normal mode press V, V, <ctrl>+v, can enter the visual mode. In the visual mode
Operation is a bit like taking the mouse to operate, select text when there is a mouse to choose the visual sense, sometimes
will be very convenient.

It is useful to switch various modes flexibly and quickly as needed.

Configure shortcut keys back to normal mode

Since no matter what mode, press once or two times <Esc> key can return to normal mode, we
You can see that the,<esc> key is often used. Because the <Esc> key is in the upper-left corner of the standard Qwert keyboard, the
On the left-hand little finger inflexible friends, it is inconvenient to press (I am so), so in the previous article
We configure the. VIMRC to map <Esc> to double-press the J key.

"Maps the ESC key to two J-Keys                                       Inoremap JJ <Esc>  

The J key is right on the basic key of the index finger of the right hand (generally there is a projection), it is very convenient to use.
If I have only one vim setting left, I will choose to keep it.

--------------------------------------------------------------------------------

In command mode, double-press two capital Letter Z, if the currently edited file has been modified, then VI save the file and exit, return to the shell; if the currently edited file has not been modified, VI exits directly and returns to the shell.

In the last line mode, enter the command

: W

VI saves the current edit file, but does not exit, but continues to wait for the user to enter the command. When you use the W command, you can then give the edit file a new file name.

[Example 6]

: w NewFile

At this point VI will save the contents of the current file to the specified NewFile, while the original file remains unchanged. If NewFile is an existing file, VI gives a hint in the status line of the display window:

File exists (use!) To override)

At this point, if the user really wants to replace the contents of NewFile with the current contents of the file, you can use the command

: w! NewFile

Otherwise, you can select a different file name to save the current file.

In the last line mode, enter the command

: Q

System Exit VI returns to the shell. If the edit file is not saved when you exit VI with this command, VI displays the following information in the last line of the display window:

No write since last change (use!) To overrides)

Prompts the user that the file has been modified without saving, and then VI does not exit, continuing to wait for the user command. If the user does not want to save the modified file and want to forcibly exit VI, you can use the command

: q!

VI Discard the changes and return directly to the shell.

In the last line mode, enter the command

: Wq

VI will save the file first and then Exit VI to return to the shell.

In the last line mode, enter the command

: X

The command functions the same as the ZZ command in command mode

-------------------------------------------------------------------------------

Refer to the original link : https://www.cnblogs.com/zzqcn/p/4619012.html

Blog is to remember that they are easy to forget things, but also a summary of their work, the article can be reproduced, without copyright. Hope to do their own efforts to do better, we work together to improve!

If there is any problem, welcome to discuss together, code if there is a problem, you are welcome to the great God!

Several modes of "vim" switching

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.