VIM syntax folding : disable folding multi-line comments

I use the "syntax" foldmethod in vim 7.3. In .vimrc:

set foldmethod=syntax

When I open Test.cpp, containing:

/* A function with a multi-line
 * comment. This takes at least
 * four lines and I want to be
 * able to read all of them.
 */
void TheFunction()
{
  DoStuff();
}

I see the following when folded:

+--  5 lines: A function with a multi-line---------------------------------------------
void TheFunction() 
+--  3 lines: {------------------------------------------------------------------------

I like the function body folding, but not the comment-folding. I want to disable it so it looks like this:

/* A function with a multi-line
 * comment. This takes at least
 * four lines and I want to be
 * able to read all of them.
 */
void TheFunction() 
+--  3 lines: {------------------------------------------------------------------------

How do I do this? I can see the syntax group that's relevant with :syn list cComment

cComment       xxx matchgroup=cCommentStart start=+/\*+ end=+\*/+  extend fold contains
=@cCommentGroup,cCommentStartError,cSpaceError,@Spell
                   links to Comment

But tooling around for an hour with the vim documentation and google hasn't told me how to remove the "fold" attribute from this group.

Is my only recourse really to edit the language syntax file? I suppose it's less ugly to copy the system syntax file and use this, but I should be able to turn off a specific group with a command in my .vimrc.

Answers


When 'foldmethod' is set to "syntax" then /* */ comments and { } blocks will become a fold. If you don't want comments to become a fold use:

:let c_no_comment_fold = 1

Need Your Help

xapth for a descendant-or-self while keeping the order of text same

php xpath xpath-2.0

I am trying to extract the text from the below html structure using xpath,

Is there a framework for both Android and iPhone development in C#?

c# android iphone .net

Basically we're looking to develop a relatively simple application, but we only want to do it once. We're a .net development house. As that is our strength, we'd like to stick with that.