PrefaceIn embedded Linux development, the need to modify the configuration file, and so on, must use VI, so familiar with the VI of some basic operations, to help improve work efficiency.
One, Mode
There are 3 modes of the VI Editor:
Command mode、
Input Mode、
last-line mode。 It is important to master these three models:
Command mode: VI starts after the default entry is the command mode, from this mode use the command can switch to the other two modes, while in any mode just click [
ESC] Key to return to command mode.
Input mode: Enter subtitles in command mode
"I"You can edit the file into the input mode of VI. In this mode we can edit, modify, input and other editing work, in the last line of the editor to display a "--insert--" Mark VI entered the input mode. We need to save the file when we have finished modifying the input, then we need to return to the command mode and save it in the last line mode.
Last-line mode: Input in command mode
":"To enter this mode, there are many useful commands in the last line mode.
Two, copy
A, copy the entire row
Command mode, the cursor is in the current row to be copied, enter
yy
b, copy a word
Command mode, the cursor is in the first letter of the current word to be copied, enter
yw
Three, paste
Command mode, enter
P
Four, delete
A, delete the entire row
Command mode, the cursor is in the row you want to delete, enter
DD
B, delete a word
Command mode, the cursor is in the first letter of the word to be deleted, enter
DW
Five, Undo
Command mode, enter
u
Six, Jump
Command mode,
Enter the number of rows to jump, and then enter GG
such as: To jump to the 150th line of the current file, enter
150gg
Linux under VI Copy, Paste, delete, Undo, jump and other commands