Linux [Electronic resources]

Janet Valade

نسخه متنی -صفحه : 357/ 239
نمايش فراداده

vi Editing Commands

vi changes the content of the text file in response to keys that you press. Table 18-2 shows the most useful commands.

Table 18-2. vi Editing Commands

Operation

Command

What It Does

Insert

i

Inserts text before the cursor. (Insert mode)

a

Inserts text after the cursor. (Insert mode)

o

Inserts a line after the current line. (Insert mode)

O

Inserts a line before the current line. (Insert mode)

A

Appends text at the end of the line. (Insert mode)

I

Inserts text at the start of the current line. (Insert mode)

Delete

x

Deletes the character under the cursor.

dd

Deletes the current line. Saves line in a buffer.

dw

Deletes the next word.

D

Deletes from the cursor to the end of the line.

Replace

rx

Replaces the current character with x.

s

Replaces one character with text. (Insert mode)

cw

Replaces a word with text you type. (Insert mode)

cc

Replaces a line with text you type. (Insert mode)

C

Replaces text from cursor to end of the line with text you type.(Insert mode)

Copy

YY

Copies a line into the buffer.

Put

p

Copies text from buffer into file following the current line.

Undo

u

Undoes the last change to the file.

U

Undoes all changes on the current line.

Help

:help

Displays a help file.

NOTE

Commands that turn on Insert mode are noted in the table. Press <Esc> when finished inserting text to return to Normal mode.