Tuesday, March 20, 2007

Vi tips

How to delete blank lines within vi?

Just type this baby in:

:g/^$/d


NOTE: This means that all the lines that just have a
carriage return on them (NO Spaces), will be removed.




Ok, so I have some of those lines too. How can I remove all of them as well?

:g/^ *$/d


NOTE: There is a space after the '^' and before the '*'.


How to remove documentation from httpd.conf within vi?
1.
Delete all lines starting with the # sign

:.,$s/^#.*$//g


2. Delete all blank lines

:g/^ *$/d

No comments: