I have a setup where I want folds to open whenever the cursor moves into a fold, including through vertical motion. I have set foldopen=all.

However, I also want to manually close folds as it makes some actions easier like deleting a whole fold. However, zc does nothing.

I've tried setting foldopen with the list of every item but all. This does allow closing folds, but this doesn't open a fold on vertical motions.

How can I have both folds that open on vertical motions but allow manually closing folds that I'm in.

  • What remain unclear to me is how you plan to do some action on the whole fold with the fold getting expanded with every vertical movement (see the NOTE in :help 'foldopen'). Nov 14, 2023 at 8:22
  • I guess that's a question of timing. If the fold is closed, and I type dd does that delete the fold immediately, or open the fold and then delete it? The note about a mapping gave me the idea to have zc be in a mapping to ignore foldopen, but that didn't work.
    – Rob Mosher
    Nov 14, 2023 at 11:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.