Reference https://www.fprintf.net/vimCheatSheet.html
1. Exit Operation:
: Q Exits when the contents of the file are not changed, and exits if there is a change in content
: q! Force quit does not save
: CQ forced exit does not save
: Wq Save and exit
: wq! Force Save exit
: Wq {file name} saved and exited when no changes were made to the file
: wq! {file name} No matter if the file is modified, force Save as another file and exit without modifying the original file
[range]wq[!] Save only the data in the range other data deleted usage is as follows:
If there is a file with the following contents:
A
B
C
D
E
So: 3,5 wq! To save only 3 to 5 rows c,d,e This three data, the range is separated by a comma between the starting and ending values to indicate that only one row is saved if there is no comma, this way wq to add!
Otherwise it will fail.
ZZ: Equivalent to wq!
ZQ: Equivalent to q!
2. Edit the file:
: E If the file is edited outside of Vim, the current file is re-edited
: e! Erase previous changes, re-modify the current file
: e {File} edits the specified file
: e! {file} ignores previous modifications, edits the specified file
GF Edit file name under cursor
3. Input operation
A ENTER after the cursor
End of A Line input
I enter before the cursor
I input before the first non-blank
GG: Jump to the first column
o Another line of editing under the cursor
O another line of editing on the cursor
4. Inserting files
: R [Name] inserts the contents of a file after the cursor
: r! {cmd} executes the cmd command, then inserts the output of CMD after the cursor
5. Delete Files
X: Delete the contents after the cursor
X: Delete the content before the cursor
6. Revocation
U: Undo Changes
: U undo a change
CTRL R: Redo All
: Red Redo an undo content
7. Encryption
: x (uppercase X) simple encryption operation, if you are not careful to this and do not want to encrypt, just two times directly return instead of entering the password
Vim Common operation