The following command is used to facilitate the review of this article because it is often difficult to read books.
If you cannot find the vim command in this article, see Linux Private food page278.
Vim has three modes: general mode, edit mode, and command line mode.
In normal mode
Move command: 0/[home] move cursor to the front of this line
$/[End] move the cursor to the end of the line
G moves to the last row of the file.
Ng moves to the nth line of the file
Gg/1g move to the first line of this file
N [enter] move the cursor down n rows
DELETE command: X, X indicates to delete a character backward, and X indicates to delete a character forward.
NX deletes n consecutive characters (N is a number)
Dd deletes the row where the cursor is located.
NDD deletes n rows down where the cursor is located
D1g delete all data from the cursor to the first row
DG deletes all data from the cursor to the last row
D $ Delete the last character from the cursor to the row
D0 deletes the first character from the cursor to the row
Copy command: yy copy the row where the cursor is located
Nyy copies the n-down line of the cursor
Y1g copy all data from the row where the cursor is located to the first row
G. Copy all data from the row where the cursor is located to the last row.
Y0 copies the character of the cursor to all data at the beginning of the row.
Y $ copy all data from the character with the cursor to the end of the row
Paste command: P, P: paste the copied data under the cursor line; P: paste the copied data on the cursor line
Other commands: Restore the previous operation
[CTRL] + R redo the previous operation
In command line mode
: Set nu display row number
: Set Nonu cancel row number
Common Vim commands