In Vim, I use the standard foldmarkers {{{,}}} with a naming convention for the folds (e.g. {{{ collection). Some named folds define a comment (e.g. {{{ documentation) and I would like these to be highlighted as such. All the folds end with the same }}} marker.
I am having some success with the following:
syn region cComment start="{{{ documentation" end="}}}"
contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold
but the problem is that commented folds can also contain generic collection folds, as in the following example:
{{{ documentation
{{{ collection
// some text
}}}
{{{ collection
// some text
}}}
}}}}
In this case, the commenting stops when the first }}} is reached, so the second collection fold is not highlighted as a comment.
The contains option does not seem relevant, as this makes contained folds have their standard highlighting.
I would like any fold inside a comment fold to inherit the comment syntax, without affecting their default syntax outside a comment fold.
Is this possible in Vim, given that all folds have the same endmarkers?
1 Answer