1

Any way to copy folds to a copied file?

Example: file1 has several folds, now I create a new file cp file2 newfile. newfile doesn't have folds that I had created in vim, of course it won't as cp and vim are different commands.

Any way to copy folds of file1 to newfile?

5
  • 2
    You might be interested in :help mkview and :help loadview
    – Zorzi
    Apr 20, 2020 at 21:13
  • mkview and loadview are for saving and loading folds of one file. Here, my question is to copy fold of one file to other file.
    – mtk
    Apr 20, 2020 at 21:38
  • mkview creates a file in viewdir which identifies the folds (among other things) of a specific view. What you can do is load this file from another view
    – Zorzi
    Apr 20, 2020 at 21:52
  • I just recorded a quick demo: zorzi.wistia.com/medias/lyoa0jo8h4
    – Zorzi
    Apr 20, 2020 at 22:05
  • 3
    cool. Thanks. Convert to answer :)
    – mtk
    Apr 20, 2020 at 22:12

1 Answer 1

1

You can use :saveas (less manipulations then with :mkview/loadview)

It will make a copy of your file and its view into a new file with its own view.
You 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.

Also answered here: https://stackoverflow.com/a/71349298/6356206

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.