Common Linux commands that developers need to be familiar with: vi

Source: Internet
Author: User

VI commandIt can be said that it is the most common command to edit files in the Unix/Linux world, but it has too many command sets, so it is not easy to be proficient in it, except for professional SA, for our developers, we only need to master some of the most common usage. The following describes some common commands:

Command Description
NG Jump to line N. N indicates the number of rows. This command immediately redirects the cursor to the specified row.
G Jump to the last line of the file
Gg Jump to the first line of the file
CTRL + G Number of rows and columns at the cursor position
: Set nu Line number displayed in the editor
CTRL-F Flip forward
CTRL-B Flip back
N + Move the cursor down n rows
N- Move n rows above the cursor
0 Move the cursor to the beginning of the current row. Note that the number is zero.
$ Move the cursor to the end of the current row
Dd Delete a row and move it up automatically
D Delete the character from the cursor to the end of the line
D0 Delete the character from the cursor to the beginning of the line. Note that the number is 0.
D $ Delete the character between the cursor and the end of the line
U Undo the last operation, similar to Ctrl + z
/Pattern Search for pattern from the beginning of the cursor to the end of the file
? Pattern Search for pattern from the beginning of the cursor
N Repeat the previous search command in the Same Direction
N Repeat the last search command in the reverse direction
: S/P1/P2/g Replace all p1 in the current row with P2. s represents substitute and g Represents global.
: N1, N2s/P1/P2/g Replace all P1 from line N1 to line N2 with P2.
: G/P1/S // P2/g Replace all p1 in the file with P2.
: N Jump to line N
I/R Change to insert/replace Mode
Q/Q! Exit/force exit without saving
: W/tmp/tmpfile Save the file to the specified file, which is particularly useful when the file is read-only.
: X/: WQ/ZZ Save and exit

 

 

Related Article

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.