These two days I was worried about finding a tool for C Development in Linux. I suddenly remembered the built-in editing tool VI in Linux. I heard that VI is a powerful tool but it has always been uncomfortable, so I am determined to study VI as a powerful tool. The following is the command for using Vi!
In VI, press I to start from or edit the current row, A to start editing in the next row of the current row, and O to add or edit a row in the last row.
In VI, there are three operation modes: A. Command mode B. insert mode C. Last line mode.
Command mode: The command mode is used when you enter VI to edit the file, or press ESC in insert mode to switch to command mode.
Command mode is mainly used to respond to some VI commands. In this mode, several commands can be used to edit documents, such as modifying the character of the cursor by pressing R, basically, documents cannot be edited at will.
The following is a command list and description in command mode:
Press the H key to move the cursor to the left (only the name of the key is given below, except for the + sign in the middle of the system key combination like CTRL)
L move the cursor to the right
J move the cursor down a line
K move the cursor up a row
0 move the cursor to the beginning of the line
$ Move the cursor to the end of the row
G move the cursor to the beginning of the last line
W move the cursor to the next word
E move the cursor to the last character of a word
B. move the cursor to the first character of a word.
{Move to the previous line with the "{" Character
} Move to the next line with the "}" Character
CTRL + B flip up
CTRL + F flip down
CTRL + u flip up half page
CTRL + D flip down half page
CTRL + e scroll down a row
CTRL + y scroll up a row
N + move n rows down from current position
Copy and edit commands
YY copy the entire row of the cursor
YW moves the cursor to the right
Nyw copies n words starting from the cursor
Nyy copies the N rows after the cursor
P paste
Delete edit command
Dd deletes the entire row where the cursor is located.
NDD deletes the N rows after and where the cursor is located.
X Delete the characters in which the feature is disabled
NX deletes the cursor and the next n characters
D + downward arrow keys Delete the next row
D + move up the arrow key to delete the previous row
Other commands
CTRL + G display the number of lines at the cursor position and total number of lines in the last line
Ng moves to row n
R: Modify the character of the cursor
R Directly replaces the character of the cursor until you Press ESC
U undo the previous operation
U cancels the operation on the current row
. Repeat the previous command
ZZ save and exit vi
% Matching Characters During programming ({
In the insert mode, simply press the insert or I key in the command mode to enter the insert mode.
Last line mode:
Press ESC +: To enter the last line mode. The following command is used:
E. Create a new file.
N load new files
W save the file
W! Force save file
Q exit
WQ save and exit
Set nu display row number
/Automatically searches for matching characters
? Character forward search matching character
These commands are just the most basic commands for VI operations. They are frequently used when I use VI. They may be helpful to new users. ^_^!