Command to enter VI
vi filename : Open or create a new file and place the cursor at the beginning of the first line
vi n filename: Open the file and place the cursor at the beginning of the nth line
vi filename: Open the file and place the cursor at the beginning of a line
vi /pattern filename: Open the file and place the cursor on the first string that matches the pattern
vi -r filename: Happened when you were editing with vi last timesystemcrashed, restored filename
vi filename.... filename: Open multiple files and edit them in turn
Move cursor class commands
h: Move the cursor to the left by one character
l: Move the cursor to the right by one character
space: Move the cursor to the right by one character
Backspace: Move the cursor to the left by one character
k or Ctrl p: Move the cursor up one line
j or Ctrl n: Move the cursor down one line
Enter: Move the cursor down one line
w or w: Move the cursor right to the beginning of a word
b or b: Move the cursor left to the beginning of a word
e or E: Move the cursor to the right to the suffix
): The cursor moves to the end of the sentence
( : Move the cursor to the beginning of the sentence.)
}: Move the cursor to the beginning of the paragraph
{: Move the cursor to the end of the paragraph
nG: Move the cursor to the beginning of the nth row
n: Move the cursor down to the n line
n-: Move the cursor up n rows
n$: The cursor moves to the end of the nth row
H: Moves the cursor to the top row of the screen
M: Move the cursor to the middle row of the screen
L: Move the cursor to the screen row
0: (note the number zero) The cursor moves to the beginning of the current line
$: Move the cursor to the end of the current row
Screen roll class commands
Ctrl u: Turn half the screen to the beginning of the file
Ctrl d: Turn the screen halfway to the end of the file
Ctrl f: Flip a screen to the end of the file
Ctrl+b; Turn the screen to the beginning of the document
nz: Scroll the nth line to the top of the screen, and if n is not specified, the current line will be scrolled to the top of the screen.
Insert text class commands
i : in front of the cursor
I : At the beginning of the current line
A: After cursor
A: At the end of the current line
o: Open a new line under the current line
O: Open a new line on top of the current line
r: Replace the current character
R: Replace the current character and the following characters until the ESC key is pressed
s: Starts at the current cursor position and replaces the specified number of characters with the entered text
Save command
Press the ESC key to jump to command mode, then:
:w Save the file but not exit vi
:w file saves the changes to the file separately without exiting vi
:w! Force save, do not push vi
:wq save the file and exit vi
:wq! Force save the file, and exit vi
Q: Exit VI without saving the file
:q! Force quit vi without saving the file
:e! Discard all changes and edit from the last time you saved the file
After that, enter the car, okay!
Command to enter VI
vi filename : Open or create a new file and place the cursor at the beginning of the first line
vi n filename: Open the file and place the cursor at the beginning of the nth line
vi filename: Open the file and place the cursor at the beginning of a line
vi /pattern filename: Open the file and place the cursor on the first string that matches the pattern
vi -r filename: The system crash occurred when I was editing with vi last time, and the filename was restored
vi filename.... filename: Open multiple files and edit them in turn
www.2cto.com
Move cursor class commands
h: Move the cursor to the left by one character
l: Move the cursor to the right by one character
space: Move the cursor to the right by one character
Backspace: Move the cursor to the left by one character
k or Ctrl p: Move the cursor up one line
j or Ctrl n: Move the cursor down one line
Enter: Move the cursor down one line
w or w: Move the cursor right to the beginning of a word
b or b: Move the cursor left to the beginning of a word
e or E: Move the cursor to the right to the suffix
): The cursor moves to the end of the sentence
( : Move the cursor to the beginning of the sentence.)
}: Move the cursor to the beginning of the paragraph
{: Move the cursor to the end of the paragraph
nG: Move the cursor to the beginning of the nth row
n: Move the cursor down to the n line
n-: Move the cursor up n rows
n$: The cursor moves to the end of the nth row
H: Moves the cursor to the top row of the screen
M: Move the cursor to the middle row of the screen
L: Move the cursor to the screen row
0: (note the number zero) The cursor moves to the beginning of the current line
$: Move the cursor to the end of the current row
www.2cto.com
Screen roll class commands
Ctrl u: Turn half the screen to the beginning of the file
Ctrl d: Turn the screen halfway to the end of the file
Ctrl f: Flip a screen to the end of the file
Ctrl+b; Turn the screen to the beginning of the document
nz: Scroll the nth line to the top of the screen, and if n is not specified, the current line will be scrolled to the top of the screen.
Insert text class commands
i : in front of the cursor
I : At the beginning of the current line
A: After cursor
A: At the end of the current line
o: Open a new line under the current line
O: Open a new line on top of the current line
r: Replace the current character
R: Replace the current character and the following characters until the ESC key is pressed
s: Starts at the current cursor position and replaces the specified number of characters with the entered text
Save command
Press the ESC key to jump to command mode, then:
www.2cto.com
:w Save the file but not exit vi
:w file saves the changes to the file separately without exiting vi
:w! Force save, do not push vi
:wq save the file and exit vi
:wq! Force save the file, and exit vi
Q: Exit VI without saving the file
:q! Force quit vi without saving the file
:e! Discard all changes and edit from the last time you saved the file
After that, enter the car, okay!
|