Monday, May 16, 2011

Editing in vi

Many keywords ease the use of vi

Some of them are:

Ctrl+F - to move forward one page at a time

Ctrl+B - to move backward one page at a time

Ctrl+D - to move half page forward at a time

Ctrl+U - to move half page backward at a time

Ctrl+G - name of the file you are editting

G -last line of the file

1G - move to the first line of the file
--
this any line no you want to move to


H - want the cursor to move to the upper left corner of the screen

M - want to move the cursor to the middle left corner of the screen

L - want to move the cursor to the lower left corner of the screen

Ctrl+R - to Redo the changes in the file

Ctrl+U - to Undo the changes in the file

dw - delete the word

d$ - delete starting from where the cursor is to the end of the line

d0 - delete starting from where the cursor is to the beginning of the line


Editing using numbers:

5cl - delete the 5 characters following the cursor and make it in insert mode

12j - move the cursor down 5 lines

3dw - delete 3 words

substitution in vi:

:g/Local - find the occurence of Local globally and print the instances

:s/Local/Remote - replace the occurence in the current line

:g/Local/s//Remote - for replacing the first occurence

:g/Local/s//Remote/g - for replacing the entire occurence of Local

:g/Local/s//Remote/gp - for replacing and printing the changed occurence

No comments:

Post a Comment