To delete a particular fold one can do zd
.
To delete all fold markers one can execute:
:%s/# {{{//
:%s/# }}}//
But is there a command (like zd
) to delete all markers?
Vim uses the same movement commands to define folds. Folding also works in visual mode. If you enter visual mode using v or V , then select a few lines of text using the movement keys, and type zf , Vim will create a fold comprising those lines. Another option is to specify a range in command mode.
Code or text folding, or less commonly holophrasting, is a feature of some graphical user interfaces that allows the user to selectively hide ("fold") or display ("unfold") parts of a document. This allows the user to manage large amounts of text while viewing only those subsections that are currently of interest.
tl;dr zE
is the command you are looking for.
Now for the long version.
Assuming:
foldmethod
is set to marker
.foldmarker
setting matches the fold markers in the file
(in your case it's the default {{{,}}}
).commentstring
is set properly (this is almost certainly the case, unless vIM doesn't have a syntax file for the file type).You can just use zE
which Eliminates all folds in the file.
You can check the settings by running :set foldmethod? foldmarker? commentstring?
and set them by running :set foldmethod=manual foldmarker={{{,}}} commentstring=#%s
.
See the docs here: http://vimdoc.sourceforge.net/htmldoc/fold.html#zE
There are some caveats in the docs here: http://vimdoc.sourceforge.net/htmldoc/fold.html#fold-delete-marker
This does not work properly when:
A line contains more than one marker and one of them specifies a level. Only the first one is removed, without checking if this will have the desired effect of deleting the fold.
The marker contains a level number and is used to start or end several folds at the same time.
I answer this myself:
To delete all fold markers, visually select all the file with ggVG
before doing a zd
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With