: w save file but do not exit VI
: W file saves the modification to file and does not exit VI
: w! Forced to save, do not launch VI
: Wq save file and Exit VI
: wq! Force the file to be saved and exit VI
Q: Do not save file, Exit VI
: q! Do not save file, Force exit VI
: e! Discard all changes and edit from the last time the file was saved
Cursor Control
H |
Cursor moves left |
J |
Cursor moves down |
K |
Cursor moves up |
L (or SPACEBAR) |
Cursors Move Right |
W |
Move forward one word |
B |
Move one word backwards |
E |
Moves one word forward, and the cursor points to the end of the word |
( |
Move to the header of the current sentence |
) |
Move to the header of the next sentence |
{ |
Move to the header of the current segment |
} |
Move to the header of the next paragraph |
[[ |
Move to the header of the current section |
]] |
Move to the header of the next section |
0 |
Move to the header of the current line |
$ |
Move to the tail of the current line |
^ |
Move to the first non-whitespace character in the current line |
+ or RETURN |
Move to the first character of the next line |
- |
Move to the first character of the previous line |
N | |
Move to the current line where the character n is |
H |
Move to the header of the current screen |
M |
Move to the middle of the current screen |
L |
Move to the tail of the current screen |
N H |
Move to n rows at the top of the current screen |
N L |
Moves to n rows at the end of the current screen |
Ctrl-f |
Move to the next screen |
Ctrl-b |
Move to the previous screen |
Ctrl-d |
Move Down half screen |
Ctrl-u |
Move Up half screen |
|
|
|
|
Z RETURN |
Refresh the screen, adjust the screen so that the current cursor in the refreshed screen after the header (is not understood??? If you don't understand it, try to know what it means. |
Z. |
Refreshes the screen, adjusts the screen so that the current cursor is in the middle of the refreshed screen |
Z- |
Refreshes the screen, adjusts the screen so that the current cursor is at the end of the refreshed screen |
Ctrl-l |
Refresh the screen without adjusting the screen position |
Ctrl-r |
Refresh the screen without adjusting the screen position |
/Text |
Search down text |
/ |
Repeat the contents of the last search to search down once |
? text |
Search up text |
? |
Repeat on this search up one time |
N |
Repeat on this search, search down |
N |
Repeat the search on this, search up |
/text/+n |
Move to the next n line of text |
? text?-N |
Move to the top n row of the text row |
|
|
|
|
N G |
Move to N rows |
:N |
Move to N rows |
G |
Move in the last row |
Content editing
A: Append content at the end of the current line
I: Insert content before cursor
I: Insert content after cursor
O: Add content below the row of your mouse
O: Add content above the row of the mouse
ESC: Exit Edit mode
CTRL-T: Move to next tab
Backspace: Move backward one character
Ctrl-u: Delete the current
CW: Delete the character of the cursor and enter edit mode
CC: Delete the row where the cursor is located and enter edit mode
C: Remove the character from the cursor's location to the end of the line and enter edit mode
DD: Delete When moving forward
NDD: Delete the nth row
D: Delete the character following the position of the current row cursor
DW: Delete the character that the zip code resides in
D}: Delete the remaining characters from the current segment
d^: Delete the character before the cursor to the beginning
c/Pat: Delete the contents of the cursor to the first match between the characters
DN: Delete the contents of the cursor after the next matching character
DFA: Deletes the contents of the current row cursor to the matching character (the matching character will also be deleted)
DTa: Delete the current line cursor to match the content between the characters (the matching character is not deleted)
DL: Delete the contents from the cursor to the last line of the screen
DG: Delete content from cursor to end of file
J: Link up and down two lines of content
P: Insert the contents of buffer after the cursor
P: Insert the contents of buffer before the cursor
Rx: replace characters with X
Rtext: Replace with text from the beginning of the cursor
U: Undo the last change
U: Restore the contents of the current line
X: Remove the character from where the cursor is located
X: Remove the characters in front of the cursor forward
N X: Delete the previous n characters, the cursor character will not be deleted
.: Revert the last change
~: Reverse the case of letters
Y: Copy the current line to the new buffer
YY: Copy when moving forward
"xyy: Copies the current row of buffer named X buffer
Ye: Copy when the end of a word
File operations
: W |
Write a file |
|
: w! |
Write file, ignore warning message |
: w! file |
Overwrite file, ignore warning message |
: Wq |
Quit editing after writing a file |
: Q |
Exit editor |
: q! |
Force Exit Editor |
: w file |
Write the contents of the file to another file |
Zz |
Exit editor, save and then exit if file is changed |
: X |
Exit editor, save and then exit if file is changed |
:n1,n2w file |
Write the contents of N1 line to N2 to file |
:n1,n2w >> file |
Append the contents of the N1 line to the N2 to file |
: E file2 |
Edit File2 in the command line mode of the current file |
: e! |
Re-loading files from disk |
: e# |
Alternating edit files |
|
|
|
|
: N |
Edit an underground line |
: n! |
Edit an underground row (ignore warning) |
|
|
: R File |
Inserting a file after a cursor |
: R! Command |
After the current line, insert the output after the command is run |
Common VI Editor Command line