Vim Python-Mode 折叠

17

我最近下载了Python-Mode。当我打开一个Python脚本时,我的函数被折叠起来了。我可以轻松展开(只需要在函数定义顶部按动作键之一即可)。但是,我无法弄清楚如何重新折叠函数。

此外,也许最重要的是,:help pymode返回一个错误('E149: Sorry, no help for pymode')。所以,我甚至无法查找文档。

如果有任何帮助将不胜感激。

3个回答

36

以下是可折叠命令列表:

zf#j creates a fold from the cursor down # lines.
zf/string creates a fold from the cursor to string .
zj moves the cursor to the next fold.
zk moves the cursor to the previous fold.
zo opens a fold at the cursor.
zO opens all folds at the cursor.
zc close a fold at the cursor.
zm increases the foldlevel by one.
zM closes all open folds.
zr decreases the foldlevel by one.
zR decreases the foldlevel to zero -- all folds will be open.
zd deletes the fold at the cursor.
zE deletes all folds.
[z move to start of open fold.
]z move to end of open fold.

你要找的是zc


5
您可以通过按下zc来关闭vim中的一个折叠。要关闭所有折叠:请按zM。这些都在Vim文档中有详细说明。

谢谢。那我找错地方了。zc和zo。 - Eric Miller

3

在你的vimrc中设置set foldclose=all将解决此问题。更多细节请参见:h fcl

当光标不在折叠区域内时,它会自动折叠。因此,不需要手动输入像zc这样的命令进行重新折叠,这是一个优点。

如果您不想使用foldclose选项,则可以在help fold-commands中找到与折叠相关的命令列表。


1
另外值得注意的是,set nofoldenable 可以确保打开文件时是“正常”的,即没有折叠。 - NeilG

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接