How might Ι automatically fold all paragraphs where every line begins with %%? Would be good for comments in TeX.

1 Answer 1


Try this setting:

 :set foldenable foldmethod=expr foldexpr=getline(v:lnum)=~'^\s*%%'
  • Thanks! it seems, though, that with this setting, it is no longer possible to create folds without this pattern with :fold.
    – Toothrot
    Oct 17, 2015 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.