Vim logo vim online Vim Book Ad

basic Tip #399: fold away empty lines

 tip karma   Rating 2/5, Viewed by 418 

created:   January 13, 2003 2:48      complexity:   basic
author:   Thomas      as of Vim:   6.0

You can fold sequences of at least two empty lines (may contain blanks) with these settings:

" fold empty lines with white spaces:
syn match MyEmptyLines "\(^[ ^I]*\n\)\+"  fold

You probably can substitute '[ ^I]' with '\s'.
If you have set 'foldcolumn' to more than 0 you can just open/close these empty lines block
by clicking the '+' or '-' with the mouse in the folder column.

 rate this tip  Life Changing Helpful Unfulfilling 

<<Mapping for quicker access to macros | Fast scroll mappings (incl. insert mode) >>

Additional Notes

Anonymous, January 15, 2003 13:07
%s/^$/d
Anonymous, January 15, 2003 13:08
Oops:
%g/^$/d
[email protected], January 15, 2003 19:34
Probably the tip aims at getting rid of empty lines from the display, not from the file.
Anonymous, January 15, 2003 23:08
exactly.
Anonymous, January 15, 2003 23:12
@ Anonymous_1 and _2:
don't forget the white spaces,
leave one empty line.
Never had a look on files created and maintained by other people ?
Deletion is NOT the problem for this tip.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo