Order 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 nth
VI + FileName: Open the file and place the cursor at the end of the line
VI +/pattern FileName: Open the file and place the cursor in the first matching string
Vi-r FileName: The last time you are using VI editing system crashes, restore filename VI filename....filename: Open more than one file, in turn edit
Move Cursor Class command
H: Move the cursor one character to the left
L: The cursor moves one character to the right
Space: The cursor moves one character to the right
Backspace: Move the cursor one character to the left
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 one word to the top of the word
B or B: Move the cursor left one word to the top of the word
E or E: Move the cursor right one word j to tail
): The cursor moves to the end of the 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 nth
n+: Move the cursor down n line
N: Move n line up on cursor
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: The cursor moves to the last line of the screen
0: (note is the number 0) the cursor moves to the current beginning
$: The cursor moves to the end of the current line
Screen Tumbling Class command
Ctrl+u: Turn to file first half screen
Ctrl+d: Turn to file tail half screen
CTRL+F: Flip a screen to the end of the file
Ctrl+b to the first screen of a file
NZ: Rolls the nth row to the top of the screen and rolls the current row to the top of the screen without specifying N.
Insert Text Class command
I: Before the cursor
I: At the beginning of the current
A: After the cursor
A: At the end of the current line
O: Open a new row below the current line
O: Open a new line above the current line
R: Replace the current character
R: Replaces the current character and its subsequent characters until the ESC key is pressed
S: replaces the specified number of characters with the input text, starting at the current cursor position
S: Deletes the specified number of rows and replaces them with the text entered
NCW or NCW: Modifying a specified number of words
NCC: Modify specified number of rows
Delete command
NDW or NDW: Deletes the beginning of the cursor and the n-1 word after it
Do: Delete to the beginning of the line
d$: Delete to end of line
NDD: Deletes the current row and its n-1 line
X or x: Deletes a character, x deletes the cursor, and x deletes the cursor before the
Ctrl+u: Deletes the text entered in the input mode
Search and Replace commands:
/pattern: Searches the end of the file for pattern from the beginning of the cursor? Pattern: Search for the first file from the beginning of the cursor pattern N: Repeat the last search command in the same direction
N: Repeat the last search command in the opposite direction
: s/p1/p2/g: Replaces all P1 in the current row with P2
: n1,n2s/p1/p2/g: All P1 in the N1 to N2 line are replaced with P2
: g/p1/s//p2/g: Replace all P1 in the file with P2
Option settings
All: List all option settings
Term: Set terminal type
Ignorance: ignoring case in search
List: Display tab stops (Ctrl+i) and line tail flag ($) Number: Display line numbers
A: Shows the number of changes made by line-oriented commands
Terse: Displays a brief warning message
Warn: show no write information when you go to another file without saving the current file
Nomagic: Allow special characters in search mode with no "" in front
Nowrapscan: Prohibit VI when the search arrives at both ends of the file, and start at the other end
MESG: Allow VI to display other users write to their own terminal information
Last line command
: N1,N2 CO N3: Copies the contents of the N1 line to the N2 line to the first N3 line
: n1,n2 m N3: Moves the contents of the N1 line to the N2 line to the lower N3 line
: n1,n2 D: Remove content from N1 line to N2 line
: w: Save the current file
: E filename: Open file filename for editing
: x: Save the current file and exit
: Q: Exit vi:q!: Do not save file and Exit VI:!command: Execute shell command command:n1,n2 W!command: The contents of N1 row to N2 line in file as input and execution of command, if not
Fixed n1,n2, which means that the entire file contents are entered as command
: R!command: Places the output of command commands on the current line.