导出 Vim 折叠?
如何从文件中导出 vim 折叠,以便将其传输到另一台机器?
例如,假设我在文件中创建折叠并将其保存在本地计算机上 - “折叠”元数据去了哪里?我可以将其复制到另一台机器上,还是必须再次手动重新创建折叠?
编辑:嗯,我注意到这可能是一个重复的问题,但仍然没有关于如何在不修改源文件的情况下保存折叠信息的答案。
谢谢
How can I export vim folds from a file, so that I can transfer it to a different machine?
For example say I create the folds in a file and save it on a local machine - where does the "folding" metadata go? Can I just copy it to another machine, or must I manually recreate the folds again?
EDIT: Hm, I've noticed this might be a duplicate question, but still there is not answer as to how to save the fold information WITHOUT modifying the source file.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
:mksession
命令保存会话,并使用vim -S Session.vim
恢复它。会话文件将恢复几乎所有内容,包括折叠(尽管对文件的更改会弄乱它)。如果您必须使用手动折叠,这是可行的,但使用其中一种自动折叠方法确实要容易得多 - 研究
indent
、syntax
和expr,并查找完全支持折叠的语法文件。
Save your session with the
:mksession
command, and restore it withvim -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
, andexpr
, and look for syntax files that fully support folding.好吧,我已经找到了一种相对轻松的方法。然而,这确实需要对源文件进行一些更改。
首先,将折叠标记设置为 java 样式 /** comment **/ 标记:
然后在我的源代码中,每当我想要折叠时,我只需键入:
这会产生折叠,正如我所期望的那样,并且比处理起来容易得多“动态”或视觉折叠。
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:
then inside my source any time I want a fold I just type:
This produces folds just as I expect them and is much easier to deal with than the "dynamic" or visual folding.