Vi usage in Linux-0.11

Source: Internet
Author: User
Vi usage in Linux-0.11-Linux general technology-Linux programming and kernel information, the following is a detailed reading. Vi Introduction and basic use
[Introduction] The vi Program is a full-screen editing program. It is fast to start and competent for editing all texts: entering, modifying, deleting, searching, replacing, copying, cutting, and pasting texts, the mouse is also supported. Vi uses two modes: Command mode and input mode. After executing the vi command, the command mode is started. At this time, any words entered are considered as commands. Run the vi command at the system prompt. The vi editing screen is displayed, and the file is copied in the buffer zone. Vi edits the copy file in the buffer zone. After editing, the user has the right to decide whether to replace the original file.

[Go to vi] vi [filename] directly edit the file vi file1 file2... edit multiple files vi-r filename at the same time to restore the interrupted file when editing.

[Exit vi] Press ESC to enter the command mode and select the following command to exit the vi editing window: q! If you do not save the disk, immediately exit the vi editing window: wq, exit the vi editing window: ZZ, wq: x, and wq: w, but do not exit vi: q and exit the vi editing window, if the file has been modified, the system will automatically prompt whether to save the disk.

[Entry Mode] a attaches the content to the cursor. A attaches the content to the row end. I attaches the content to the cursor. I adds the content to the beginning of the row. o adds a line under the row where the cursor is located. O add a line above the row where the cursor is located.

[Exit input mode] Press ESC to exit input mode

[Move the cursor command] The basic commands are as follows: h. move the cursor to the left. One character j. move the cursor to the right. One character 0: move the cursor to the beginning of the line. $ move the cursor to the end of the line. ^ move the cursor to the line. H move to the screen. move upper M to the middle of the screen L move to the bottom of the screen G move to the end of the file + move to the first line of the next line-Move to the first line of the previous line (move to the beginning of the next sentence {move to the beginning of the previous paragraph} Move to the next line n of the first nG segment to the file

[Screen movement command] One page at a time. One page at a time.

[Basic Editing Command] d. Delete y. Copy p. Place c. Modify

[DELETE command] Delete dO to the first dw of the row where the cursor is located Delete to the end of the word where the cursor is located d3w Delete to the end of the third word dW Delete to the next space db Delete to the last space dd Delete current row

Ndd Delete n rows (backward delete) from current row dL Delete to last row on screen

DH deletes the first line on the screen. dG removes the character from the cursor to the end of the file. s deletes the character from the cursor and enters input mode. S deletes the row from the cursor, and enter input mode x Delete the character where the cursor is located X Delete the previous character where the cursor is located

[Modify command] r modifies the character at the cursor position. r then enters the character to be corrected. cc modifies the current row. cw modifies to the end of the word.

[Move, copy, and undo command] y copies text to the buffer zone nyy copies n lines of text to the buffer zone p places the deleted or copied buffer content below the cursor r replaces the character where the cursor is located into another character u cancel the previous execution command U cancel all changes to the row J merge the two rows

[SEARCH Command]/search for a string from the position of the cursor? The string is searched forward from the cursor position. The string n is searched downward. The N is searched upward.

[Environment setting]: number of rows displayed by set nu: number of rows not displayed by set nonu: case-insensitive for set ic search: case-insensitive for set noic search

[Execution command]: e filename edit another file: r filename load another file from where the cursor is located: n move the cursor to line n: s string replacement (for example, starting line number, end row number s/replaced string/g): w Write File: q exit vi: q! Force exit vi (some modifications will be lost)

: X write the file and exit vi: wq. Same as above: wq! Write the file forcibly and exit vi.

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.