创建新折叠时阻止 Vim 打开所有后续闭合折叠

发布于 2024-08-19 01:56:19 字数 201 浏览 4 评论 0原文

我注意到,当我创建一个新折叠(我使用的是 foldmethod=marker)时,我正在创建的折叠下面的所有折叠都会自动打开。有没有办法防止这种情况并使它们关闭?

我无法使用 zf 手动创建折叠,因为我正在编辑 PHP/HTML 文件,并且没有适合两者的 'commentstring' 格式。

I noticed that when I create a new fold (I'm using foldmethod=marker), all the folds below the one I'm creating are automatically opened. Is there a way to prevent this and leave them closed?

I can't use zf to manually create a fold because I'm editing a PHP/HTML file, and there is no 'commentstring' format good for both.

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

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

发布评论

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

评论(3

执笏见 2024-08-26 01:56:19

不仅可以通过在之前创建结束标记来实现
打开一个,还可以通过在标记中指定折叠级别。

{{{1
    Fold you are closing.
    Inserting the closing marker below would not open the next fold.
}}}

{{{1
    Closed fold.
}}}

在这种情况下,折叠级别可以帮助 Vim 找到匹配的结束
标记,而不是尝试关闭下一个折叠的标记。

It is possible not only by creating the closing marker before the
opening one, but also by specifying the fold level in markers.

{{{1
    Fold you are closing.
    Inserting the closing marker below would not open the next fold.
}}}

{{{1
    Closed fold.
}}}

In this case, the fold levels helps Vim to find matching closing
marker and not try one that closes the next fold.

岁月染过的梦 2024-08-26 01:56:19

尝试在创建 {{{ 开始之前创建 }}} 结束标记
标记。这应该可以防止 Vim 混淆并打开
以下折叠。

另外,如果您发现不小心打开了一些折叠,只需重新加载
使用 :e 命令编辑文件以重置它们。

Try creating the }}} end marker before creating the {{{ start
marker. This should prevent Vim from getting confused and opening the
following folds.

Also, if you find you accidentally open some folds, just reload the
file for editing with the :e command to reset them.

奶气 2024-08-26 01:56:19

我倾向于使用 V 在视觉上标记要折叠的区域,然后使用 zf 创建折叠,而不是手动输入标记。

这不会打开任何尚未打开的折叠。

Rather than typing out the marks by hand, I tend to visually mark the reigon I want to fold with V then use zf to create the fold.

This does not open any folds that aren't open already.

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