1. Working mode
Command mode (A,i,o and other keys)--"Input mode
Input mode (ESC key)--"Command mode
Command mode (: Key)--end-of-line mode
Last-line mode (ESC key)--"Command mode
2.vim using commands
1) Cursor Movement
Cursor direction move ↑, ↓, ←, → top, bottom, left, right
Turn PAGE DOWN or ctrl+f down a full page of content
Flip page UP or ctrl+b up a full page of content
Quick Jump Home or number "0" jump to the beginning of the line
Inline quick Jump End or "$" jumps to the beginning of the line
Quick jump between rows 1G or GG jump to the top of the file
Quick jump between rows G jump to the end of the file line
Quick jump between rows #G jump to File # #
Line number display: Set NU displays line numbers in the editor
Line number display: Set Nonu Cancel editor row number display
2) Copy, paste, delete
Delete a single character x or del at the cursor
Delete the current cursor line DD
Deletes the # line content starting at the cursor #dd
Deletes all characters before the current cursor to the beginning of the d~
Deletes all characters at the end of the line at the current cursor d$
Copy the contents of the entire row of the current line to the Clipboard yy
Copy the # line content that starts at the cursor #yy
Paste the contents of the buffer after the cursor position P
Paste at cursor position before P
3) file Content Search
/word from top to bottom in file find string "word"
Word bottom finds the string "word" in a file
N locates the next matching found string
N locates the previous matched lookup string
4) cancel Edit and save exit
U press Cancel the most recent operation, press U repeatedly, redo the multi-step operation
U is used to cancel all edits made to the current line
ZZ saves the current file contents and exits the VI editor
5) Save file and Exit VI Editor
Save File: W
Save file: W/root/newfile Save As other file
Exit Vi:q not modified exit
Exit Vi:q Discard changes to the contents of the file and Exit VI
Save Exit Vi:wq
6) Open a new file or read the contents of another file
: E ~/install.log to open a new file for compilation
: R/etc/filesystems reads the contents of other files in the current file
7) file content replacement
: S/old/new replaces the first character "old" string found in the current row with "new"
: S/old/new/g replaces all the string "old" found in the current row with "new"
: #,# All Strings "old" found in line number "#,#" range replaced with "new"
S/old/new/g
:% s/old/new/g All the strings found in the entire file range "old" replaced by "new"
: s/old/new/c a C command at the end of a replacement command, prompting the user for confirmation of each substitution action
Linux VIM Editor