Preben Randhol wrote:
Hi
This is probably a stupid question, but does anybody have a setup for
folding vimscripts? In most other languages the folding are either
included or one can download scripts from vim.org. However, I cannot
find any script for folding vimscripts.
I'm interested mostly in folding:
function! boo()
....
endfunction
Thanks in advance
Preben
The most versatile folding method is "marker". It does, however, require
that you add a comment like
" {{{1
(or similar) at the end of the 1st line of every fold. Nested folds are
possible, by increasing the number after {{{ ; see also the zf zF and
":fold" command. For instance, to create a pair of fold markers for the
lines currently highlighted in Visual mode, make sure 'foldmethod' is
set to "marker" for the current window then enter ":fold", which will
change automatically to ":'<,'>fold" (without the double quotes) meaning
"from start to end of the latest Visual area".
I think you might also try ":set foldmethod=syntax" which relies on the
language syntax. Not sure if it works for Vim scripts, but it ought to.
Then again, if your script is properly indented, you can use ":set
foldmethod=indent" which requires no setup but may create too many
nested folds for your taste. A last possibility would be to write a
folding-expression yourself and use foldmethod=expr
Then, if you want to apply a particular folding method to a particular
script, you can do it by means of a |modeline|, for instance a line with
" vim: fdm=marker
near the top or bottom of the file. (By default it has to be within 5
lines from the top or bottom.)
See
:help fold.txt
:help 'foldmethod'
:help 'foldexpr'
:help modeline
:help 'modeline'
:help 'modelines'
Best regards,
Tony.