liunx edit file command

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 the line
vi /pattern filename : open the file and place the cursor at the first string that matches pattern
vi -r filename : the system crashed while editing with vi last time, restore filename
vi filename....filename : open multiple files, Edit in sequence

Move cursor class command

h: cursor moves left by one character
l: cursor moves right by one character
space: cursor moves right by one character
Backspace: cursor moves left by one character
k or Ctrl p: cursor moves up one line
j or Ctrl n: cursor Move down one line
Enter: move the cursor down one line
w or W: move the cursor right one word to the prefix
b or B: move the cursor left one word to the prefix
e or E: move the cursor right one word to the end
): move the cursor to the End of sentence
( : the cursor moves to the beginning of the sentence
}: the cursor moves to the beginning of the paragraph
{: the cursor moves to the end of the paragraph
nG: the cursor moves to the beginning of the nth line
n: the cursor moves down n lines
n-: the cursor moves up n lines
n$: Move the cursor to the end of the nth line
H: Move the cursor to the top line of the screen
M: Move the cursor to the middle line of the screen
L: Move the cursor to the screen line
0: (note the number zero) Move the cursor to the beginning of the current line
$: Move the cursor to the end

of the current line Screen scrolling commands

Ctrl u: Turn to the beginning of the file by half a screen
Ctrl d: Turn to the end of the file by half a screen
Ctrl f: Go to the end of the file Flip a screen
Ctrl+b; flip to the first screen of the file
nz: scroll the nth line to the top of the screen, if n is not specified, scroll the current line to the top of the screen.

Insert text command

i: before the cursor
I: at the beginning of the current line
a : after the cursor
A: at the end of the current line
o: open a new line below the current line
O: open a new line above the current line
r: replace the current character
R: replace the current character and the characters after it, until you press the ESC key
s : Starting from the current cursor position, replace the specified number of characters with the input text to

save the command

Press ESC to jump to the command mode , then:

:w Save the file without exiting vi
:w file Save the changes to the file separately without exiting vi
:w! force save, do not launch vi
:wq save file and exit vi
:wq! force save file, and exit vi
q: do not save file, exit vi
:q! do not save file, force quit vi
:e! discard all Modify, start editing from the last time you saved the file

, press Enter, ok!

Enter the vi command

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 the line
vi /pattern filename : open the file and place the cursor at the first string that matches pattern
vi -r filename : the system crashed while editing with vi last time, restore filename
vi filename....filename : open multiple files, Edit in
sequence www.2cto.com
Move cursor class command

h: cursor moves left one character
l: cursor moves right one character
space: cursor moves right one character
Backspace: cursor moves left one character
k or Ctrl p: cursor moves 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 one word to the prefix
b or B: move the cursor left one word to the prefix
e or E: move the cursor right one word to the end of the word
) : move the cursor 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 line
n: move the cursor down n lines
n-: move the cursor up n line
n$: the cursor moves to the end of the nth line
H: the cursor moves to the top line of the screen
M: the cursor moves to the middle line of the screen
L : Move the cursor to the screen line
0: (note the number zero) Move the cursor to the beginning of the current line
$: Move the cursor to the end of the current line
www.2cto.com
Screen scrolling commands

Ctrl u: Scroll half a screen to the beginning of the file
Ctrl d: Scroll half a screen to the end
of the file Ctrl f: Scroll one screen to the end of the file
Ctrl+b; turn one screen to the beginning of the file
nz: Scroll the nth line to the top of the screen, if n is not specified, scroll the current line to the top of the screen.

Insert text commands

i: before the cursor
I: at the beginning of the current line
a: after the cursor
A: at the end of the current line
o: open a new line below the current line
O: open a new line above the current line
r: replace the current character
R: replace the current character and the characters after it, until you press ESC key
s: starting from the current cursor position, replace the specified number of characters with the input text

Save the command

Press the ESC key to jump to the command mode , then:
www.2cto.com
:w Save the file but don't exit vi
:w file save changes to file separately, don't exit vi
:w! force save, do n't exit vi
:wq save file and exit vi
:wq! force save file and exit vi
q: don't save file, Quit vi
:q! Force quit vi without saving the file
:e! Abandon all changes and start editing from the last time the file was saved

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325483393&siteId=291194637