vim:加载文件后自动展开仅折叠在 .pm 文件中?

发布于 2024-12-05 03:20:33 字数 394 浏览 1 评论 0原文

这是我的整个 .vimrc

set ignorecase
set scs
let perl_fold=1
hi Folded cterm=bold ctermfg=yellow ctermbg=lightblue
set modeline
set hidden

加载 .pm 文件(通常只包含一个 package)时,该文件的所有代码都是折叠成一条线,我要做的第一件事就是展开折叠。

有没有办法让 vim 在加载文件后自动展开该折叠?我正在设想某种加载后钩子,它允许我判断整个文件(或超过 90%)是否折叠成一行,然后自动展开该折叠。 (如果文件开头有空行,则可能需要“超过 X %”条件,因为它们不会折叠。)

Here is my entire .vimrc:

set ignorecase
set scs
let perl_fold=1
hi Folded cterm=bold ctermfg=yellow ctermbg=lightblue
set modeline
set hidden

When loading a .pm file (which usually contains just a single package), all of the file's code is folded into a single line, and the first thing I have to do is to expand that fold.

Is there a way to have vim automatically expand that fold after loading the file? I em envisioning some sort of post-load hook which would allow me to say if the entire file (or more than 90%) is folded into a single line, then automatically expand that fold. (The "more than X %" condition might be needed if there are blank lines at the beginning of the file since they don't get folded.)

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

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

发布评论

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

评论(1

小女人ら 2024-12-12 03:20:33

您可以尝试(在您的 vimrc 中:

au BufReadPost *.pm normal zo

参考::help :autocmd, :help BufReadPost

You could try (in your vimrc:

au BufReadPost *.pm normal zo

For reference: :help :autocmd, :help BufReadPost

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