Sunday, June 10, 2012

Quick hint to use vi

vi Cheatsheet 
dd to delete line
/string Search forward for string
?string Search back for string
:s/pattern/string/flags Replace pattern with string according to flags.
g Flag - Replace all occurences of pattern
c Flag - Confirm replaces.
& Repeat last :s command

A to go to end of line and Insert mode
$ to go to end of line

I to go to first of line and Insert mode
0 to go to first of line

1G Move to the first line of the file
G Move to the last line of the file
nG Move to nth line of the file
:n Move to nth line of the file

No comments: