Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6926597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:56:19+00:00 2026-05-27T10:56:19+00:00

In Vim, I use the standard foldmarkers {{{ , }}} with a naming convention

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:56:20+00:00Added an answer on May 27, 2026 at 10:56 am
    " Hi. Two syntax regions aren't enough, you have to use a third. There
    " are two important things to note. First, 'matchgroup' (see :help
    " :syn-matchgroup) prevents contained items from matching in the start
    " and end patterns of the containing item. Second 'transparent' (see
    " :help :syn-transparent) allows the inheriting of an item's containing
    " syntax colouring.
    "
    " Save this entire text in a file and then :source it to see the effect.
    "
    "   blah
    "   {{{ collection
    "       blah
    "   }}}
    "   blah
    "   {{{ documentation
    "       {{{ collection
    "           blah
    "       }}}
    "       blah
    "       {{{ collection
    "           blah
    "       }}}
    "   }}}
    "   blah
    "   {{{ collection
    "       // some text
    "   }}}
    "   blah
    
    syn clear
    
    hi documentation guifg=darkcyan ctermfg=darkcyan
    hi collection guifg=darkmagenta ctermfg=darkmagenta
    
    syn region genericdoc start="{{{" end="}}}" transparent
    syn region collection start="{{{ collection" end="}}}"
    syn region documentation matchgroup=documentation
    \ start="{{{ documentation" end="}}}" contains=genericdoc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use vim as my editor but I would like to get some of
I use vim on webfaction through putty and would like to change the colours
I would like to use Vim to match a regular expression and perform a
I use vim under iterm2. I'm using the NERDCommenter plugin, and I'd like to
I usually use Vim, and its great for the ability to do faster some
I want to learn the vim documentation given in the standard help file. But
I'd like to use Vim for editing sources and Xcode for all other purposes
Most time when I copy or delete some code in Vim use yy or
I basically use vim to write some simple C# code snippets. Visual Studio is
I like to use VIM to quickly generate snip of codes from text. Now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.