Using Vi editor

by Nithya 2010-01-29 21:43:48

To open vi editor

$ vi filename
filename is the name of the file

There are two modes in vi. They are Insert mode and Command mode
--> press i to switch to insert mode (can insert text)
--> press ESC to switch to command mode (can give commands)
--> press :w to Save the file
--> press :q to quit the file
--> press :wq to save and quit the file

Arrow
Replacing text in vi

c can be used to change text from the cursor

--> press cw - it changes to the end of a word
--> press c2b - back two words
--> press c$ - to the end of line
--> press c0 - to the beginning of line

Arrow
Deleting text in vi

--> press dw - it deletes a word beginning where the cursor is positioned
--> press dd - it deletes entire line
--> press 2dd - it deletes two continuous lines

Tagged in:

986
like
0
dislike
0
mail
flag

You must LOGIN to add comments