开发者

How to mantain or export folds when copying a file in Vim

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 f开发者_StackOverflowolder).

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜