Thank Vim's folding, I can hide irrelevant parts of code/document and work on a small spot of the file. More and more I organize the folded first lines as an outline of the whole file, in each level. Therefore I wonder if I can selectively highlight some text over the appearance of folded parts?

I think to modify(overload) the syntax pattern of the group Folded with something like "contains=..." so that some embedded text in the headers can be highlighted differently.

However, I can't get the syntax pattern of Folded with:

:syn list Folded

, although I can see all the highlight groups for the current file type. (e.g. helpHeader)

I went searching in /usr/share/vim/vim74/syntax/ but in vain. Folded is not defined there. (neither in the neighborhood)

Do I really have a chance to highlight my fully folded document and make it more interesting? (Vim 8 or future plan?)


No you cannot. The Folded syntax highlighting is a single highlighting group that will apply to all folded text inside your file. You can neither modify it to highlight certain parts of a folded line differently, nor can you make different folds appear in a different style not can you highlight different folds in different buffers differently.

For the same reason, folded text cannot be syntax highlighted, because basically syntax highlighting rules would have to apply on top of the folded text part and that is simply not possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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