Search code examples
vimcode-folding

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 folder).

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


Solution

  • 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.