我们可以在VIM中指定多个折叠板吗?

发布于 2025-01-18 15:21:55 字数 205 浏览 3 评论 0原文

我正在尝试使用 :setfoldmethod=marker 在 vi​​m 中折叠多行我已经完成了 :setfoldmarker={,} 有什么方法可以让我们折叠函数具有起始大括号='['和结束大括号=']',并且还使用起始大括号='{'和结束大括号='}'折叠函数,就像在 vscode 中一样,我们可以使用任何起始和结束大括号折叠任何函数。

I am trying to fold multiple lines in vim with :set foldmethod=marker I have done :set foldmarker={,} is there any way such that we can fold function that has starting braces='[' and end braces=']' and also fold a function with starting braces='{' and end braces='}' like in vscode we can fold any function with any starting and ending braces.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

四叶草在未来唯美盛开 2025-01-25 15:21:55

来自 :helpfolding:

There are six methods to select folds:
    manual      manually define folds
    indent      more indent means a higher fold level
    expr        specify an expression to define folds
    syntax      folds defined by syntax highlighting
    diff        folds for unchanged text
    marker      folds defined by markers in the text
  • marker 由于 :help 'foldmarker' 下给出的原因而无济于事:

    标记是一个文字字符串(正则表达式太慢)。
    

    请参阅:帮助折叠标记

  • diff 无关紧要。

    参见:help Fold-diff

  • syntax 可能会有所帮助,具体取决于语言以及该语言的语法脚本的编写方式。

    请参阅:帮助折叠语法

  • expr 是最强大的方法,因为它可以让准确地决定折叠什么以及如何折叠它。

    出于显而易见的原因,它也是最难设置的。请参阅:help Fold-expr

  • indent 是一种相当愚蠢的方法,这使得它非常节省内存且用途广泛。您可以尝试一下,因为它根本不关心大括号。

    请参阅:帮助折叠缩进

  • 然后是手动方法,它允许您通过动作定义折叠。

    这可以让您执行诸如 zfi{zf12j 之类的操作。

    请参阅:帮助折叠手册

From :help folding:

There are six methods to select folds:
    manual      manually define folds
    indent      more indent means a higher fold level
    expr        specify an expression to define folds
    syntax      folds defined by syntax highlighting
    diff        folds for unchanged text
    marker      folds defined by markers in the text
  • marker won't help for the reason given under :help 'foldmarker':

    The marker is a literal string (a regular expression would be too slow).
    

    See :help fold-marker.

  • diff is irrelevant.

    See :help fold-diff.

  • syntax may help, depending on the language and how the syntax script for that language was written.

    See :help fold-syntax.

  • expr is the most powerful method because it lets you decide exactly what to fold and how to fold it.

    It is also the hardest to set up, for obvious reasons. See :help fold-expr.

  • indent is a pretty dumb method, which makes it very memory efficient and versatile. You could try that one because it doesn't care about braces at all.

    See :help fold-indent.

  • And then there is the manual method, which lets you define folds with motions.

    This lets you do things like zfi{ or zf12j.

    See :help fold-manual.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文