Linux introduction and Common commands using the 3--VI editor

Source: Internet
Author: User

1. order to enter VI

VI FileName: Opens or creates a new file and places the cursor at the beginning of the first line "new file"
VI +n FileName: Open the file and place the cursor at the beginning of the nth line "For example: the number of rows for a shell error"
VI + FileName: Open the file and place the cursor at the end of the line "append function"
VI +/pattern FileName: Opens the file and places the cursor at the first string that matches the pattern
"Vi +/.com makaidong" "Vi +/is Makaidong"

Insert input Press once: Overwrite override "Replace"
: w: Save current file
: Wq: Save and exit the current file
: x: Save current file and exit
: q!: Do not save file and Exit VI


2. Move Cursor Class command "All in non-insert cases"

: Set number Displays line numbers
Backspace: Delete cursor to the left
Delete: Remove cursor to the right
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 beginning of the word
B or B: The cursor moves left one word to the beginning of the word
E or E: Move the cursor right one word to the end of the word
End: Move cursor to end of sentence $
Home: Cursor moves to sentence 0: (note is number 0)
PageUp: Prev
PageDown: Next Page
NG: Cursor moves to the beginning of nth
n+: The cursor moves down n rows
N: Move the cursor up n rows
H: Move the cursor to the top row of the screen
M: Move the cursor to the middle line of the screen
L: The cursor moves to the last line of the screen


3. Screen Tumbling Class command

Ctrl+u: First half screen "up" to file
Ctrl+d: Half screen "down" to the end of the file
Ctrl+f: Turn one screen to the end of the file "down"
Ctrl+b to the top of the file.

4. Delete command

DD Delete Bank
NDD: Deletes the current line and its subsequent n-1 rows
YY Copy Bank
P Paste


5. Search and Replace commands

/pattern: Searches for pattern at the end of the file from the beginning of the cursor
? pattern: Searches for pattern from the beginning of the cursor to the top of the file
N: Repeat the last search command "Next" in the same direction
N: Repeat the previous search command in the opposite direction "reverse previous"
: s/p1/p2/g: Replaces all P1 in the current row with P2
: n1,n2s/p1/p2/g: All P1 in line N1 to N2 are replaced with P2 ": 2,7s/ma/ma666/g"
: g/p1/s//p2/g: Replace all P1 in the file with P2 ": g/ma/s//ma5555/g"
G/makaidong/s//macaihong/g
G/macaihong/s//makaidong/g

5. Line Mode command

: N1,N2 CO N3: Copy the contents of the N1 line to the N2 line under the N3 line "similar to copy copy: 2,3 Co 10"
: n1,n2 m N3: Moves the contents of the N1 line to the N2 line below the N3 line "move similar to clip: 2,3 m 18"
: n1,n2 D: N1 The contents of rows to n2 delete delete ": 6,8 D"


Linux introduction and Common commands using the 3--VI editor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.