The cursor movement operation of VI command in Linux

Source: Internet
Author: User

In a full screen text editor, the movement of the cursor is undoubtedly the most frequently used operation. The user is skilled at using these commands to move the cursor to quickly and accurately reach the desired location for editing.

The cursor movement in VI can be either in command mode or in text input mode, but the method of operation is different.

In text input mode, you can move the cursor directly using the four arrow keys on the keyboard; in command mode, there are many ways to move the cursor. Not only can you use four arrow keys to move the cursor, you can also use H, J, K, l these four keys instead of four arrow keys to move the cursor, so as to avoid the different machines on the different keyboard definitions brought by the contradictions, and the use of skilled hands can not leave the letter keyboard position can complete all operations, thereby improving efficiency.

The following command completes the cursor movement in command line mode:

The h cursor moves to the left, if enters the number n before pressing the H command, then moves the cursor to the left n characters;

L The cursor moves to the right, if the number n is entered before the L command, the cursor is shifted to the right n characters;

The J cursor moves up, and if you enter a number n before pressing the J command, the cursor moves n characters;

K cursor down, if you enter the number n before the K command, the cursor Xia to move n characters;

0 (0) the cursor moves to the beginning of the line;

The $ cursor moves to the end of the line;

The H cursor moves to the first line displayed on the screen (not necessarily a file header);

The L cursor moves to the last line displayed on the screen (not necessarily the end of the file);

The M cursor moves to the middle line of the screen;

The NG cursor moves to the nth line;

W or W moves the cursor right to the beginning of the next word;

E or E If the cursor start position is within a word (that is, not at the end of a word), the command moves the cursor to the ending of the word, and if the cursor starts at the end of the word, the command moves the cursor to the suffix of the next word.

B or B if the cursor is within the word (that is, not the first word), the command moves the cursor to the beginning of the word, and if the cursor is at the beginning of the word, the command moves the cursor to the beginning of the previous word;

Ctrl+g status Command, which displays the status of the currently edited document. Includes the file name that you are editing, whether it has been modified, the current line number, the number of rows in the file, and the percentage of the line before the cursor that occupies the entire file.

Alternatively, you can complete the movement of the cursor throughout the file by following the command in the last row mode:

: n the cursor moves to the nth row of the file;

: $ The cursor moves to the last line of the file;

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.