Red Flag asianux Server 3 System Management: Using the VIM editor

Source: Internet
Author: User
Keywords Asianux vim Editor
Tags beginning editor enter text file function key keys note

VIM since its inception, after constant innovation, now the latest version of Vim has a very powerful function, so that users can more easily and conveniently use it.

5.1 Vim's working mode

5.1.1 Command mode

In command mode when you start to enter Vim, press <ESC> to return to command mode if you are already in insert mode or last line mode. In this mode, you can only use the key command, you cannot enter text.

5.1.2 Insert Mode

Insert mode is to insert text into the file you want to edit, and the insertion position varies according to the command you are using. Entering insert mode from command mode requires typing I, a, O, R, and I, A, O, R, and so on. After you finish entering text, you must return to command mode with the <ESC> key.

5.1.3 Last line mode

The last line mode is named after the command appears at the bottom of the screen. In the command mode, type some special characters, such as/、?、:, and so on, the cursor jumps to the end of the screen and displays the last line of characters you typed, and then returns when you type the command, and VIM displays certain response information on the last line as needed and automatically returns to the command state.

The basic process of 5.2 vim editing files

At the command line, type Vim testfile, where testfile represents the name of the file you want to open, and if the file does not exist, VIM will automatically create a new file named Testfile.

Enter Vim, press <i> key into insert mode, you can do the work of writing documents. The cursor can be moved by the arrow keys. <BackSpace> button to delete the previous character.

After writing the file press <ESC> key can return to the command mode, and then use: W Archive (note, is the colon command), then will not leave Vim, to leave can press: Q, can also be combined with: Wq, on behalf of the preservation of leaving.

5.2.1 Cursor Movement

Note: The actions in command mode are described in this section.

5.2.1.1 Basic Cursor Movement

Left h backspace or LEFT ARROW key

Next J Enter or + or DOWN ARROW keys

Up K-or UP ARROW keys

Right l space or right ARROW key

Page DOWN CTRL PageDown

Page UP Crtl+b PageUp

5.2.1.2 Complex cursor Movement

0 to the beginning of the line or the <Home> key
~ Move to the first non-white-space character
$ move to end of line, or <End> key
G moves to the end of the file (the first non-white-space character on the last line)
GG to the top of the file (first blank character at the first line)
W Move to next word
W ditto but ignores some punctuation
e move to the end of the previous word
E ditto, but ignores some punctuation
b move to the first word
B ditto, but some punctuation is ignored
H move to the first non-white-space character at the top of the screen
M moves to the first non-white-space character in the middle of the screen
L move to the first non-white-space character on the bottom of the screen
n| Move to Nth character
: N or N G moves to the beginning of the nth line, Note: n indicates the specific number, such as 1,2,3 ...
) to the beginning of the next sentence
(move to the top of the previous sentence
Move to the beginning of the next paragraph
{Move to top of previous paragraph

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.