I have a file consisting in about a hundred paragraphs, each one being folded according to the third example under the :help fold-expr section, which makes a fold out of paragraphs separated by blank lines :
set foldmethod=expr
set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1
Suppose I launch a search pattern, e.g.
/Item 014
This pattern may be found in 7 of the different folds.
I know I could just press "n" 6 times to open successively all the folds concerned by the search.
But I would like to have the 7 folds opened in one move, in order to have a quick overview.
I tried a macro
qu n q
then
/Item 014
100@u
but failed.
How should I proceed ?
After having performed your search for /Item 014
, you can use the following command to open all folds containing the pattern:
:g//foldopen
This takes advantage of the fact that the :g
command reuses the last search pattern when left empty. The Ex command :foldopen
is thus executed on all matching lines: it opens the fold on the current line.
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