Monthly Archives: July 2011

You are browsing the site archives by month.

vi – Used To Hate It

Over the past few months editing configuration files and writing scripts, not programming, I’ve come to realize how awesome vi is and the plethora of operations you can perform on the text once you open it up in “vi”. Forget about nano/pico. Some common tasks you can do with vi…

Find and Replace: “g” indicates global or else vi only replaces once per instance per line.

:%s/find/replacewith/g

Find and Replace a “\”(windows) with a “/”(*nix):

:%s/\\/\//g

Line Numbers:

:set number

Go To Line Number:

:lineNumber

Remove Line Numbers:

:set no number

Search For Text(Case Sensitive):

/searchstring

Delete All Lines Starting With a Particular Character(“;” in this case):

:g/^;*$/d

Delete All Empty Lines:

:g/^$/d