I have a file (filetype=javascript), this is how it looks without folds:

the file without folds

and with folds:

the file with folds

I can move with the { and } motions skipping the empty lines inside the folds (thanks to these question and answer). But trying to delete a paragraph brings the problem of folds again:

My cursor is on line 1. I'm pressing d} and expecting Vim to delete the fold below completely, like on the screen shot below (as it would do, if no empty lines were in the fold):

expected result of deletion of a fold

Instead this happens (the last line of the fold has not been deleted):

the last line of the fold has not been deleted

If I'm doing the opposite motion to delete backwards (in this example the cursor is on the last line in the file), I'm expecting Vim to delete the previous fold (the one above), like here:

delete the previous fold

Instead this happens (the text has been deleted up to the first encountered empty line):

the fold has not been fully deleted

I looked into the docs :h 'foldopen' and haven't understood well what this means:

When a movement command is used for an operator (e.g., "dl" or "y%") this option is not used. This means the operator will include the whole closed fold. Note that vertical movements are not here, because it would make it very difficult to move onto a closed fold.

I thought that vertical motions are not supported with the operator commands, as this seemingly states, but, for instance, d3j did the job. Isn't j a vertical movement command?

Could anyone tell me, please, how and if can I use the { and } motions with operator commands, especially d? Thank you.

  • Could you edit the question with 1) example input, 2) the output you're getting, 3) the output you're expecting, and 4) the filetype you're using? An incomplete screenshot is not all that helpful I'm afraid. – Martin Tournoij Jun 23 '17 at 20:47
  • @Carpetsmoker, I have edited the question – user907860 Jun 23 '17 at 21:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.