Basic Linux vim operations and basic Linux vim operations
1. display the number of rows
Input
: Set number or: set nu
2. move the cursor
H. move the cursor to the left.
J move the cursor downward
K move the cursor up
L move the cursor to the right
N <space> n is a number, and the space cursor moves n characters successively.
0 or move the home Key to the beginning of the line
$ Or end key move to the end of the row
W moves to the header of the next word
B Move to the first of the previous word
E. Move to the end of the next word.
Ge moves to the end of the previous word.
Move gg to the beginning of the file
G moves to the last row of the file
NG n moves the number to the specified row.
H/M/L respectively move to the top, middle, and end of the screen
Number plus H/M/L, the number of rows from the top
3. File Search
In normal mode
/Word searches for 'word' characters from the cursor position backward
? Word searches for the 'word' character forward from the cursor position
4. File Deletion
Delete one character from x, X in lowercase, and one character from forward in uppercase x
N-digit nx. n characters are deleted from the backend.
Dd deletes the row where the cursor is located.
Ndd n is data, and n rows are deleted from the cursor position.
D1G Delete the cursor position and previous rows
DG deletes the cursor position and subsequent rows
DnG deletes the cursor position to n rows
D $ Delete All characters from the cursor position to the end of the line
D0 deletes the character from the cursor position to the beginning of the line
5. File Replication
Y usage is similar to d File Deletion
P paste the copied content
6. File Search
: N1, n2s/word1/word2/g replace all word1 with word2 between line n1 and line n2
: 1, $/word1/word2/g full-text search and replacement
: 1, $/word1/word2/gc full-text search replace c confirm before replacement, confirm
7. Undo and reverse undo
In normal mode, enter u to cancel the previous operation.
Reverse revocation of crel + r in the first edition Mode
8. Save and exit the file
: Wq saved and released
: Q exits when it is changed.
: Q! Force exit and do not save
: W <filename> Save as another file
: N1, n2 w <filename> Save n1 to n2 as the specified file