【发布时间】:2012-04-06 02:30:28
【问题描述】:
我在 vim 7.3 中使用“语法”折叠方法。在 .vimrc 中:
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 list cComment 相关的语法组
cComment xxx matchgroup=cCommentStart start=+/\*+ end=+\*/+ extend fold contains
=@cCommentGroup,cCommentStartError,cSpaceError,@Spell
links to Comment
但是使用 vim 文档和 google 花了一个小时的工具并没有告诉我如何从该组中删除“折叠”属性。
我唯一的办法真的是编辑语言语法文件吗?我想复制系统语法文件并使用它不那么难看,但我应该能够使用 .vimrc 中的命令关闭特定组。
【问题讨论】:
-
kev 的回答完美。这可以在文档
:help ft-c-syntax的 syn-file-remarks 部分找到。你也可以用let c_no_if0_fold = 1折叠#if 0风格的cmets。