->Title Page
->Intro
->Unix
->Vi editor
-->Basics
-->Vi reference
-->Miscellaneous tips
--->Line deletions
--->Switching cases
--->Spell checking
--->Advanced S and R
->Blank lines
--->Buffers
->Mirror sites
->Further reading

[ Up ]
[Prev][Home][Next]
[Author]

Vi ---> Removing blank lines

Blank lines can be removed from a file with any of the following:


    :v/./d
or


    :g/^$/d
or


    :%!cat -s
If you want to get rid of duplicate blank lines, but leave the first blank line intact, try:


    :%!sed /./,/^$/!d
Be aware that you may need to get rid of trailing whitespace first. This can be accomplished with


    :%s/[ ^I]*$/

Please notify owners of webpages with outdated links to these pages

Find this site useful? Want to give something back?

© 1993-2001 Christopher C. Taylor