Syntax folding in Vim makes it easy to create folds for regions, the start and end of which can be defined with regular expressions:
syn region myRegion start="#region" end="#endregion" transparent keepend extend fold
However, I am not sure how I can use syntax folding to define folds for C++-style comments, which are sets of lines beginning with "//".
I think I found a solution:
:syn match comment "\v(^\s*//.*\n)+" fold
This is a multiline match that folds consecutive lines beginning with whitespace and double slashes. The "\v" in the beginning labels the pattern "very magic" for brevity. Seems to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With