vim:加载文件后自动展开仅折叠在 .pm 文件中?
这是我的整个 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试(在您的
vimrc
中:参考:
:help :autocmd
,:help BufReadPost
You could try (in your
vimrc
:For reference:
:help :autocmd
,:help BufReadPost