Aix System VI Editor Basics

Source: Internet
Author: User
Tags exit command line save file

1. Launch editor

$ VI file_name

If the file exists, you can open the file or create a new file.

2, vi Editor's status

There are two states of the VI Editor:

(1) Command status

Can enter a variety of instructions to achieve VI editing function or SET VI environment

(2) Text input status

Can be directly used for text manipulation

When you open or create a new file with VI, you are first in the command state.

3, the use of VI

(1) Add text

1.a: Add text after the current character

2.A: Add text at the end of the current line

3.i: Add text before the current character

4.I: Add text at the beginning of the current line

5.O: Add a new row after the current line

6.O: Add a new line before the current line

After the above command, that entered the text input state, you can enter a variety of text characters. Such as

To end the text entry status, return to the command state by pressing the ESC key.

(2) Delete text

1.X: Delete Single character

2.DW: Delete to current suffix

3.d$: Delete to the end of the current line

4.D0: Delete The current beginning of the line

5.DD: Delete When moving forward

6.:20,40D: Delete line 20th to 40 lines

(3) Query

1./text: Query backwards

2.?text: Forward Query

3. N: Find Next

(4) Modify text

1.R: Modify the current character

2.R: Overwrite the character until the ESC key is pressed

3.S: Deletes the current character and adds the character until the ESC key is pressed

4.S: Deletes all characters in the current line and adds characters until you press ESC

(5) Moving text

The VI Editor can store the contents of the most recent delete or copy operation in a buffer. So-called text moving

The use of this feature, the need to move the text into the buffer, and then use the Paste function to the text

The word is placed in a new position.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/unix/

1.yy: Deposit current line into buffer

2.DD: Deletes the current line and stores the contents in a buffer

3.P: After placing the contents of the buffer in the current position

4.P: Place the contents of the buffer before the current position

(6) File Save

W: Save File

(7) Exit VI Editor

1.:q: Exit VI

2.:q!: Forced Exit VI, (not save)

4. Set VI environment variable

VI Environment variables can be set in two ways: VI command or $HOME/.EXRC file

(1) Use VI's command to set

: Set All

: Set

: Set Number/nonumber

: Set List/nolist

: Set Showmode/noshowmode

: Set Tabstop=x

: Set Ignorecase/noignorecase

: Set wrapmargin=5

The settings made with the VI command can only be maintained until Exit VI.

(2) Set in $HOME/.EXRC file

You do not need to add a colon to a set before the. exrc file

When you start VI, the program first looks for the. exrc file, which, if it exists, is set by that file VI

environment; if the. exrc file is not found, it uses the built-in true province settings.

5, use VI function in the command line

To set the VI feature on the command line

$ Set-o VI

Press the ESC key again, and then edit the command as you would in the VI environment.

K--Displays the last used command

J--Displays the next used command

H--Move the cursor to the left

L--Move right

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.