gpt4 book ai didi

Vim 离开折叠时自动折叠

转载 作者:行者123 更新时间:2023-12-02 04:28:57 25 4
gpt4 key购买 nike

我想让 vim 在我离开时自动关闭我的折叠。意味着当我的光标位于折叠中时,应该显示折叠,但是当它位于(比方说)折叠端下方 5 行时,它应该再次关闭。

这些是我的折叠设置:

set foldenable
set foldlevel=0
set foldnestmax=1
set foldmethod=indent
set foldtext=FoldText()

function FoldText()
return '...'
endfunction

可以找到完整的源代码here

我该怎么做?据我所知,vim 没有提供任何针对此功能的选项,因此必须有一些 autocmd

博多

最佳答案

Vim 提供了执行此操作的选项,称为'foldclose',要像这样运行,请将其设置为all

更多详细信息请参阅它的帮助:

'foldclose' 'fcl'   string (default "")
global
{not in Vi}
{not available when compiled without the |+folding|
feature}
When set to "all", a fold is closed when the cursor isn't in it and
its level is higher than 'foldlevel'. Useful if you want folds to
automatically close when moving out of them.

关于Vim 离开折叠时自动折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24711212/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com