John Degen wrote:
I expected :g/^\d/fold to create a fold of all lines matching ^\d, but nothing
happens, except that the search string is higlighted. My 'foldmethod' is
'manual'. What am I missing?
John
":fold" expects a |range|. You don't supply one. What the above does is put
the cursor on every line starting with a digit and executing ":fold" on each
of them, creating (IIUC) a one-line fold for every line starting with a digit.
Try (untested)
function FoldNumbered()
normal! gg
while search('^\d','W')
let l = search('^\_[^[:digit:]]','nW')
if l
exe '.,' . (l-1) . 'fold'
else
.,$fold
endif
endwhile
endfunction
Best regards,
Tony.
--
Different all twisty a of in maze are you, passages little.