Commonly used commands of the vi editor in Linux system: linuxvi

Source: Internet
Author: User

Commonly used commands of the vi editor in Linux system: linuxvi

Vi is a text editor in Linux. Beginners may be troubled by a large number of commands. Here, I have screened some common commands for your reference.

Common commands for accessing vi:

Vi filename: open or create a file and place the cursor at the beginning of the first line

Vi + filename: open the file and place the cursor at the beginning of the last line

I. Common commands for inserting text

Command description

I... insert text before the current character

I... insert text at the beginning of the row

A... add text after the current character

A... add text at the end of the row

O... insert an empty row behind the current row

O... insert an empty row before the current row

R · input text in rewriting Mode

2. Common commands for moving the cursor

Command description

J or down arrow... move a row down.

K or the up arrow... move a row up.

H or left arrow... move one character to the left

L or right arrow... move one character to the right

W · shift one word right

W · shift right of a word separated by Spaces

B · move a word left

B · move left a word separated by Spaces

0... moved to the beginning of the line

Ctrl F... flip the page forward

Ctrl B · flip back

NG · to line n

G · to the last line

3. Common commands for replacing text

Command description

$ To the end of the line

At the beginning of a sentence

) To the end of a sentence

Before the beginning of a paragraph

} To the end of the paragraph

4. Common commands for deleting texts

Command description

R · replace a character

C. Modify the text until you Press Esc.

Cw modify the next word

Cnw rename the next n words

5. Save and exit Common commands

Command description

Zz · Save and quit

: W filename · writing files

: W · writing files

: X · Save (if the previous file has been modified) and exit

: Q! · Do not save the file and exit directly

: Q... 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.