2012-04-06 98 views
5

我在vim 7.3中使用“语法”foldmethod。在的.vimrc:VIM语法折叠:禁用折叠多行注释

set foldmethod=syntax 

当我打开Test.cpp的,含有:

/* 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(); 
} 

我看到折叠时执行以下操作:

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

我喜欢的功能体的折叠,但不评论折叠。我想禁用它,所以它看起来像这样:

/* 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: {------------------------------------------------------------------------ 

我该怎么做?我可以看到语法组的相关搭配:SYN列表cComment

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

但模具周围与Vim文档一个小时,谷歌还没有告诉我如何从该组删除“折叠”属性。

我唯一的办法就是编辑语言语法文件吗?我认为复制系统语法文件并使用它不太难看,但我应该能够使用.vimrc中的命令关闭特定的组。

+0

kev的答案完美的作品。这可以在文档':help ft-c-syntax'的syn-file-remark部分找到。您还可以用'let c_no_if0_fold = 1'来折叠'#if 0'样式注释。 – reasgt 2012-04-06 18:15:23

回答

5

'foldmethod'设置为"syntax"然后/* */ comments{ } blocks将 成为折叠。如果你不想让评论成为折叠使用:

:let c_no_comment_fold = 1