在 Vim 中复制文件时如何维护或导出折叠

发布于 2024-08-19 15:37:17 字数 144 浏览 4 评论 0原文

每次我复制文件时,折叠都会丢失。我明白为什么会发生这种情况,但我无法弄清楚如何“导出”或“维护”折叠。有什么建议吗? (否则如果我复制整个文件夹,我必须一个一个地重命名视图文件)。

编辑:我通过书写来折叠线,例如: :1,80 fo

Every time I copy a file the folds are lost. I understand why this happens, but I can''t figure out out to "export" or "maintain" the folds. Any suggestions? (otherwise I have to rename the view files one by one if I copy a entire folder).

EDIT: I'm folding lines by writting for instance: :1,80 fo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

王权女流氓 2024-08-26 15:37:17

阅读可爱的手册,:help Foldmethod

对于您正在使用的手动折叠:

当您放弃文件时,手动折叠将会丢失。要保存折叠,请使用
:mkview 命令。稍后可以使用 :loadview 恢复视图。

或者,您可以设置foldmethod=marker,然后:fold将在您的文件中添加{{{}}}< /code> 指示折叠位置。由于默认值为 manual,因此您必须在模型行或 vimrc 中将其设置为 marker

Read the lovely manual, :help foldmethod.

With the manual folds you are using:

The manual folds are lost when you abandon the file. To save the folds use
the :mkview command. The view can be restored later with :loadview.

Or, you can set foldmethod=marker, and then :fold will litter your file with {{{ and }}} to indicate where the folds are. Since the default value is manual, you'll have to set it to marker, either in a modeline or in your vimrc.

别念他 2024-08-26 15:37:17

或者您可以使用 :saveas

它将把您的文件及其视图复制到一个具有自己视图的新文件中。
您的原始文件和视图将保持不变。

:edit original.md
:saveas copy.md

唯一的缺点是,如果您有文件标记(AZ),它们将被移动(不是复制,移动)到您的新文件中。

Or you can use :saveas.

It will make a copy of your file and its view into a new file with its own view.
Your original file and view will be left untouched.

:edit original.md
:saveas copy.md

The only downside is that if you have file marks (A-Z), they will be moved (not copied, moved) to your new file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文