Search This Blog

Tuesday, April 1, 2008

Basic VI Editor Commands

Cursor Movements

h, j, k, l

Move left, Down, Up, Right

0

Move to First Character of the Line

$

Move to end of Line

w

Move to next word

CTRL + D

Move Page Down

CTRL + U

Move Page Up

G

Move to the End of File

1G or :1

Move to the Top of File

nG

Move to Line number n. (replace n is any integer value)

CTRL + G

Display current Line Number


 

Find a Text

/text

Find a text in Forward Direction

?text

Find a text in Reverse Direction

n

Repeat the previous Search


Note: text needs to be replaced by the string that needs tobe searched.

 

Editing, Inserting orDeleting a Text

a

Append after Cursor

A

Append to the end of Line

i

Insert before cursor

I

Insert from the Beginning of the line

o

Insert a new Line in the edit mode

cw

Change word

cc

Change whole line

C

Change text to end of line

dd

Delete Current Line

5dd

Delete current line and next 4

D

Delete from Current Position to the end of line

u

Undo last change

U

Restore Current Line


 

Copy(yanking) and Paste

yy

Yank a copy of Current Line

p

Insert previously yanked Line


 

Saving and Exiting

ZZ or :wq

Save and exit file

:q!

Exit without Saving

:w filename1

Save edited file as filename1. Similar to Save as.

1 Comment:

sap ecc 7.0 said...

Great. I do find difficulty in learning all the commands and looks for them every time I need them. But from now onwards it will be easy to me as I got all the editor commands with their usage listed in your article. I have bookmarked it and would like to Thank you for sharing it from core of my heart.

Copyright (c) All rights reserved. Presented by Suresh Vaishya