【问题标题】:VIM syntax folding : disable folding multi-line commentsVIM 语法折叠:禁用折叠多行注释
【发布时间】: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。

标签: c++ vim


【解决方案1】:

'foldmethod' 设置为 "syntax" 时,/* */ comments{ } blocks 将 变成折叠。如果您不希望 cmets 成为折叠使用:

:let c_no_comment_fold = 1

【讨论】:

    猜你喜欢
    • 2013-02-11
    • 2011-04-23
    • 2011-07-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-16
    • 2010-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多