1. Three status Modes 2. Common VI commands
: E filename (open a new file to the VI editor)
: E! Filename (open a new file to the VI editor and discard modifications to the current file)
: R filename (read file content to the current VI editor)
: W (Save the changes to the files opened in the VI editor)
: W myfile (Save the content in the VI editor as the specified file name)
: Q (the files opened in the VI editor are not modified, or the changes have been saved. Exit the VI editor directly)
: WQ (Save the files in the VI editor and exit the VI editor)
: Q! (Discard modifications to the file content and exit the VI editor)
: Set nu (display the row number in the editor)
: Set Nonu (cancel row number display in the editor)
Ng (jump to the nth line in the file (in command mode ))
G (jump to the end of the file (in command mode ))
Dd (delete the row where the cursor is located)
NDD (delete n rows from the row where the cursor is located)
U (cancel the last operation and restore the operation result. You can use the U command multiple times to restore the multi-step operation that has been performed)
YY (copy the entire row of the current row to the VI buffer)
Nyy (copy the N rows starting from the current row to the VI buffer)
P (read the content in the VI buffer and paste it to the current position of the cursor (not overwrite the existing content of the file ))
/Word (search for the string "word" in the file from top to bottom ")
? Word (search for the string "word" in the file from the bottom up ")
N (locate the next matched string)
N (locate the last matched string)
: % S/old/new/g (replace all strings "old" with "new" throughout the file ")