Two modes:
■ Normal mode (Normal Mode)
■ Insert mode)
In insert mode, press escape to enter normal mode. In normal mode, press I to enter insert mode.
The insert mode is used to edit text. commands are generally used in Normal Mode:
Positioning:
■ H shifts left.
■ J move down.
■ K move up.
■ L right shift
■ Pagedown (or CTL-f) rollback
■ Pageup (or CTL-B) rollback
■ G last line
■ Num Gg to row num
■ Gg's first line
Save and exit:
■ Q exit
■ Q! Force exit and do not save
■ W filename is saved to the filename File
■ WQ save and exit
Edit:
X deletes the current character.
Dd deletes the current row
DW deletes the word where the current cursor is located. For example, int word CH, the entire word can be deleted.
D $ Delete the cursor position to the end of the row.
J. Delete the linefeed at the end of the row where the current cursor is located.
When a is added at the cursor position, it is actually to move back and switch to the insert mode.
Adding a after the current row actually means moving to the end of the row to switch to the insert mode.
R char replaces the current character with a char character
R text overwrites text from the current position until you Press ESC.
Search:
Press/to enter the string to be searched. Press enter to start searching. Press n to locate the next search result.
Replace:
Press: Enter the command to perform the replacement operation.
■: S/old/new/g Replace in the current row
■: #, # S/old/new/g replace between #,# rows
■: % S/old/new/g Replace the entire file
■: % S/old/new/GC is replaced in the entire file, but a prompt is displayed.