Wednesday, March 23, 2011

Vi Commands

Start of the line    0
End of the line $
Start of the file  :1
End of the file  <esc>G
Save and quit :wq
Save and quit in a read-only file :wq!
Save and exit ZZ
Change globally in current line   :s/OLD/NEW/g
Search and delete line containing the pattern :g/Stress Inside/d
Search and replace word/delete word :%s/word/new word/g   >> gc--if you want confirmation
Change word   :cw
Change line :C
Show line numbers  :set number
Delete line numbers (example line 1 to 4 )  :1,4d
Copy line Y
Paste line P

Motion:
w move to the next word
W move to next delimeted word
b back to the word

No comments:

Post a Comment