Exporting Vim folds?

我的未来我决定 提交于 2019-12-05 10:46:32

Save your session with the :mksession command, and restore it with vim -S Session.vim. The session file will restore almost everything, including folds (though changes to the file will mess it up).

That works if you must use manual folds, but it's really a lot easier to use one of the automatic fold methods — investigate indent, syntax, and expr, and look for syntax files that fully support folding.

Ok I've figured out a relatively painless way of doing it. This does require some change to the source file however.

First, set the fold-marker to be java style /** comment **/ markers:

:set foldmethod=marker
:set foldmarker=/\*\*,\*\*/

then inside my source any time I want a fold I just type:

/** This is the title of the section */
Some stuff goes here blah
...
//the line below "ends" the fold by double star
/* **/

This produces folds just as I expect them and is much easier to deal with than the "dynamic" or visual folding.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!