Linux text editor vi

Source: Internet
Author: User
Tags linux text editor
1. Three status Modes 2. Common VI commands

: E filename (open a new file to the VI editor)
: E! Filename (open a new file to the VI editor and discard modifications to the current file)

: R filename (read file content to the current VI editor)

: W (Save the changes to the files opened in the VI editor)
: W myfile (Save the content in the VI editor as the specified file name)

: Q (the files opened in the VI editor are not modified, or the changes have been saved. Exit the VI editor directly)
: WQ (Save the files in the VI editor and exit the VI editor)
: Q! (Discard modifications to the file content and exit the VI editor)

: Set nu (display the row number in the editor)
: Set Nonu (cancel row number display in the editor)

Ng (jump to the nth line in the file (in command mode ))
G (jump to the end of the file (in command mode ))

Dd (delete the row where the cursor is located)
NDD (delete n rows from the row where the cursor is located)

U (cancel the last operation and restore the operation result. You can use the U command multiple times to restore the multi-step operation that has been performed)

YY (copy the entire row of the current row to the VI buffer)
Nyy (copy the N rows starting from the current row to the VI buffer)
P (read the content in the VI buffer and paste it to the current position of the cursor (not overwrite the existing content of the file ))

/Word (search for the string "word" in the file from top to bottom ")
? Word (search for the string "word" in the file from the bottom up ")
N (locate the next matched string)
N (locate the last matched string)

: % S/old/new/g (replace all strings "old" with "new" throughout the file ")

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.