2

Working in an index with mucked up manual folds. Would like to delete folds from current line to end of file.

Have tried:

:.,$zd

and

:.,$df

So far I've just done a visual selection from current line to end of file and keyed in:

zD

to delete all folds recursively in the selection. Works, but would be nice if there was a way to enter a range instead.

Thoughts?

1

You can use the :normal command to execute a normal command such as zD for all lines in a range.

To execute that command in all lines from the current one until the end of the file, you can use:

:.,$normal! zD

I'm using :normal! to ignore any mappings affecting the zD command and use Vim's native definition of that command. (But if you don't have any such mappings, using :normal is just fine.) You can also abbreviate the command to :norm if you like.

1
  • 1
    I’m actually surprised there’s not a fold-delete ex command. Nope, only fold, foldopen/foldclose, and folddoopen/folddoclosed – D. Ben Knoble Sep 9 '20 at 13:26
0

I'm not sure if it's a good idea, but you can wrap it into Ex command:

command! -bar -range DeleteFolds execute printf("normal! %dGV%dGzD", <line1>, <line2>)

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.