eeeeaaii
eeeeaaii

Reputation: 3460

How do I preserve folds in VIM when cutting and pasting?

In vim, you can create a fold with zf, so if is %, you can neatly fold a delimited block.

Upvotes: 5

Views: 705

Answers (2)

Jay
Jay

Reputation: 57959

Vim has several different fold strategies; I assume you are talking about manual folding.

Unfortunately, yanking and pasting does not keep the fold in-tact. You may be able to create a script that will re-fold pasted text, but it seems like it would be more annoying than useful in the end.

Upvotes: 1

Daniel DiPaolo
Daniel DiPaolo

Reputation: 56408

  • You can do the first if you use :set foldmethod=manual and then simply highlight the block you want and use zf to fold it.
  • I don't think you can do this (at least, not without a script)

Upvotes: 3

Related Questions