我想让 vim 在我离开时自动关闭我的折叠。意味着当我的光标位于折叠中时,应该显示折叠,但是当它位于(比方说)折叠端下方 5 行时,它应该再次关闭。
这些是我的折叠设置:
set foldenable
set foldlevel=0
set foldnestmax=1
set foldmethod=indent
set foldtext=FoldText()
function FoldText()
return '...'
endfunction
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?据我所知,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.
Run Code Online (Sandbox Code Playgroud)