Summary of using the vim terminal editing command in Ubuntu

Source: Internet
Author: User
I. after VIM highlight enters vim, enter the following command in normal mode to enable php code highlighting: syntaxenable: source $ VIMRUNTIME/syntax/php. vim 2. VI common commands _______________________________________________________________ General mode cursor movement _____

I. VIMHighlight

After entering vim, enter the following command in normal mode to enable php code highlighting:

: Syntax enable

: Source $ VIMRUNTIME/syntax/php. vim

II. VICommon Commands

_______________________________________________________

Move cursor in normal mode

__________________________________________________________

H or move a character toward the left arrow key

J or downward arrow key move the cursor down a character

K or move the cursor up to a character

L or move the cursor one character to the right

Ctrl + f move a page forward (commonly used)

Ctrl + B move one page backward (commonly used)

Ctrl + d move the screen forward for half a page

Ctrl + u flip back half page

+ Move the cursor to the next column with a non-space character

-Move the cursor to the previous column of a non-space character.

N Press the space key next to the number, and the cursor will move to the right

N characters, for example, 20 , The cursor will move 20 characters to the right

0 (this is the number 0) move to the first character of this line (commonly used)

$ Move to the last character of this line (commonly used)

H move the cursor to the row at the top of the screen

M move the cursor to the row in the center of the screen

L move the cursor to the bottom of the screen

G moves to the last line of the file (commonly used)

NG moves to the nth line of the file. for example, 20 GB will move to

20th rows (can be used with: setnu)

N Move the cursor down n rows (commonly used)

________________________________________________________________

Search and replace in normal mode

________________________________________________________________

/Word search for a string named word before the cursor

? Word searches for a word string named before the cursor

: N1, n2s/word1/word2/g searches for the word1 string between line n1 and line n2 and replaces the string

Is word2 (commonly used)

: 1, $ s/word1/word2/g search for the word1 string from the first row to the last row, and replace the string

Is word2 (commonly used)

: 1, $ s/word1/word2/ge searches for the word1 string from the first row to the last row, and replaces the string

It is word2, and a prompt is displayed before replacement to ask the user to confirm (confirm) (frequently used)

__________________________________________________________________

Delete copy and paste in normal mode

__________________________________________________________________

X, X: deletes one character backward, and x is deletes one character forward (commonly used)

Nx deletes n characters from the backend

Dd delete the whole line of the cursor (commonly used)

Ndd deletes n rows down the row where the cursor is located. for example, 20 DD deletes 20 rows (commonly used)

D1G delete all data from the row where the cursor is located to the first row

DG deletes all data from the row where the cursor is located to the last row

Yy copy the row where the cursor is located (commonly used)

Nyy copies n rows down from the row where the cursor is located. for example, 20 YY copies 20 rows (commonly used)

Y1G copy all data from the row where the cursor is located to the first row

YG copies all data from the row where the cursor is located to the last row.

P and P are copied data and pasted to the next row of the cursor. p is pasted to the previous row of the cursor (commonly used)

J. Combine the row where the cursor is located with the data of the next row into a row.

U recovery previous action (commonly used)

____________________________________________________________________

Edit mode

___________________________________________________________________

I, I insert: Insert the input text at the position of the current cursor. The existing characters are backward

Withdrawal (commonly used)

A, A Add: the input starts with the next character at the position of the current cursor, and the existing character

Backward (commonly used)

O, O insert a new line: start from the beginning of the next line where the cursor is located and enter characters (commonly used)

R, R replace: r will replace the character pointed by the cursor: R will always replace the character pointed by the cursor

Text until you press Esc (commonly used)

Exit the editing mode of Esc and return to normal mode (commonly used)

___________________________________________________________________

Command line mode

___________________________________________________________________

: W writes edited data to hard disk files (commonly used)

: W! If the file attribute is read-only, the file is forcibly written.

: Q exit vi (commonly used)

: Q! If you have modified the file and do not want to save it, use it! Force exit without saving files

: Wq is saved and exited. if it is: wq !, It is forced to save and exit (commonly used)

: W [filename] Save the edited data as another File (similar to saving a new file)

: R [filename] reads data from another argument in the edited data, that is

File content is added to the end of the row where the cursor is located

: Setnu: Display the row number. after this parameter is set, the row number of the row is displayed before each row.

: Opposite to setnu, setnonu is the canceled row number.

N1, n2 w [filename] save the content from n1 to n2 as filename.

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.