Vim:仅折叠顶层折叠 [英] Vim: Fold top level folds only

查看:32
本文介绍了Vim:仅折叠顶层折叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Vim 中有一个带有语法折叠的长代码文件.

I have a long code file with syntax folding in Vim.

我知道如何打开所有折叠 (zR) 或关闭所有折叠 (zM),并且我知道如何增加或减少折叠级别 (zm, zr).

I know how to open all folds (zR) or close all folds (zM), and I know how to increase or decrease the foldlevel (zm, zr).

然而,当我增加折叠级别时,最里面的折叠是关闭的;相反,我希望最外面的折叠关闭,而最里面的折叠则展开.可以通过打开所有折叠并手动关闭每个顶级折叠来手动执行此操作,特别是对于我快速打开以获取代码概述的长文件而言,这是令人难以置信的乏味.

However when I increase the foldlevel the inner most folds are closed; instead I want the outer most folds closed while the inner most are unfolded. It is possible to do this manually by opening all folds and the closing each top level fold by hand it's incredible tedious specially with long files that I open quickly to get an overview of the code.

是否有任何快捷键可以做到这一点?或者我是否需要制作某种 Vim 函数来做到这一点?如果是这样,如何?

Is there any key shortcut to do this? Or do I need to make some sort of Vim function to do this? And if so, how?

推荐答案

是的,你可以输入

:%foldc

关闭一层折叠(由外向内).

Which closes one level of folds (outside in).

这篇关于Vim:仅折叠顶层折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆