vi quick reference

I have a need to refer to some vi commands that I keep forgetting every now and then. My favourite is busybox vi, and I have extensively tested all commands below. They should work in whatever vi you might use. I assume, by inference, all others are supersets of busybox vi. If not, please let me know.

Gjump to end of file
gg
1G
:0
jump to beginning of file
5G
:5
jump to line number 5
 
d$
D
delete to end of line
d0
d^
delete to beginning of line
 
:.,$ddelete to end of file
:1,.ddelete to beginning of file
 
:g/pattern/ddelete all lines containing the string "pattern"
:g!/pattern/d
:v/pattern/d
delete all lines not containing the string "pattern"
 
:1,$s/pattern1/pattern2/gsearch & replace all "pattern1" with "pattern2"

No comments:

Post a Comment

most viewed