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

jQuery mobile add new markers to an existing map

javascript jquery-ui jquery-mobile google-maps-api-3

I am working with the jQuery mobile google maps example here, focusing on the first "Basic Map Example".

Is there a limit to number of arguments in stringWithFormat?

string cocoa nsstring

I'm trying to compose an email using MFMailComposeViewController and I'm using a HTML string wich draws a table. It has 265 arguments so I have to pass it like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.