2

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

icktoofay
  • 126,289
  • 21
  • 250
  • 231
alexchenco
  • 53,565
  • 76
  • 241
  • 413

2 Answers2

2

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.

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
1

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.

hulius
  • 189
  • 1
  • 8