Vim Tips Wiki

Fold away empty lines

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 399 Printable Monobook Previous Next

created 2003 · complexity basic · author Thomas · version 6.0

You can fold sequences of two or more empty lines (may contain whitespace) with these settings:

:syn match MyEmptyLines "\(^\s*\n\)\+" fold
:syn sync fromstart
:setlocal foldmethod=syntax

After entering the above, type zM to close all folds, or zR to open them.

If you have set 'foldcolumn' to more than 0 you can open/close the empty-line blocks by clicking the '+' or '-' with the mouse in the folder column.

See alsoEdit


Thanks for the tip, it works indeed, but appears to be very slow. Hundreds of empty lines have been added on a file I must look at, but it takes 30s before I can view the result -any idea ?



Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki