The shortcut key of command and the editing method under vi command
four。 Operating system command shortcut
1) use the arrow keys ↑ ↓-quickly access history commands (all input commands will be temporarily saved in memory-> saved in disk files)
2) move the cursor quickly
Ctrl + a-quickly move the cursor to the beginning of the line
Ctrl + e-quickly move the cursor to the end of the line
Ctrl + ← →-move the cursor quickly from side to side according to the word
3) Quick operation command information
Ctrl + u-cut the contents in front of the cursor
Ctrl + k-cut the content behind the cursor
Ctrl + w-cut each string information with spaces as delimits
Ctrl + y-paste the cut
4) Special feature shortcuts
Ctrl + c (cancel)-interrupt or cancel the command execution process
Ctrl + l (clear)-clear screen operation
Ctrl + s-enter the locked state
Ctrl + Q-exit locked state
five。 Edit command using method vi/vim
1) Edit command mode information
Command mode: can realize special function operation
Edit mode: you can edit file content information
Bottom line mode: you can enter special command information wq q wq! Q!
Command mode-I-> edit mode-esc- > command mode -:-> bottom line mode-esc- > command mode
2) Command mode-> edit mode
I-enter edit mode directly at the cursor position
I-switch the cursor to the beginning of the line to enter edit mode
A-enter edit mode with one character below the cursor
A-switch the cursor to the end of the line and enter edit mode
O-insert a new line below the line of the cursor and enter the editing state
O-insert a new line above the line of the cursor and enter the editing state
S-delete the character where the cursor is located and enter the editing state
S-delete the line of the cursor and enter the editing state
3) Command mode-> bottom-line mode:-enter the bottom-line mode to complete the functional operation wq! Q! /-search file information n look down N look up?-search file information n look up N look up PS: ignore case to find data in files: / oldboy\ c
4) how to move the cursor quickly (command mode)
G-switch to the last line of the file
Gg-switch to the first line of the file
100g-switch to the file specified line
100ggMurray-switch to the file specified line
^-switch to the beginning of a line
$- switch to the end of a line
5) how to complete special editing operations
Yy-copy the specified line information
Nyy-copy multiple lines of information
P-paste the copied content on the specified line
Np-paste the copied content multiple times on the specified line
Dd-delete the specified line information (essentially cut)
Ndd-delete the specified multi-line information (essentially cut)
DG-delete all lines after the cursor
C-delete the content after the cursor and enter the editing state
R-replace the specified character information
R-continuously replace multiple character information
6) Command mode special function operation
U-withdraw operation undo
Ctrl+r-cancel the withdrawal of redo
Bottom line mode special function operation: set nu-display line number information: set nonu-cancel line number display
7) Common errors in editing commands
Error 01: edit commands can only edit files
Error 02: you must specify to edit the file
Error 03: edit file directory must exist
Error 04: error message is displayed and cannot be edited properly
Analyze the cause of the problem:
1) A sudden interruption occurred while editing the file
2) the file was edited by multiple users at the same time
Problem solving: problem 1: solution the first course: recover the data information before the interruption vi-r edit file information the second course: delete a hidden file description: in the linux system. The beginning of the file is to hide the file using ls-a to view the hidden file rm-f / oldboy/.oldboy.txt.swpvi command execution principle 1) Editing the file will produce a hidden file 2) is to edit the content directly in the hidden file 3) when saving the file, the hidden file is renamed