Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #399 - Fold away empty lines

Created: January 13, 2003 2:48 Complexity: basic Author: Thomas Version: 6.0 Karma: 2/5 Imported from: Tip#399

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.

Comments

%s/^$/d

Anonymous , January 15, 2003 13:07


Oops:

%g/^$/d

Anonymous , January 15, 2003 13:08


Probably the tip aims at getting rid of empty lines from the display, not from the file.

kartikeya_rindani--AT--hotmail.com , January 15, 2003 19:34


exactly.

Anonymous , January 15, 2003 23:08


--AT-- 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.


Anonymous , January 15, 2003 23:12


Advertisement