The following patch adds foldexpr option that will fold sections separated by sequences of `=' (foldlevel=1) and `-' (foldlevel=2).
# HG changeset patch # User ZyX <[email protected]> # Date 1299087044 -10800 # Node ID 8d0b25fb6467b5ab90699e485aee1ed6dec0c205 # Parent 0139403c8eb088d58773f7e76dc2a025719a8e8c Added foldexpr for help files
diff -r 0139403c8eb0 -r 8d0b25fb6467 runtime/ftplugin/help.vim
--- a/runtime/ftplugin/help.vim Fri Feb 25 18:38:36 2011 +0100
+++ b/runtime/ftplugin/help.vim Wed Mar 02 20:30:44 2011 +0300
@@ -11,9 +11,16 @@
let s:cpo_save = &cpo
set cpo&vim
-let b:undo_ftplugin = "setl fo< tw< cole< cocu<"
+let b:undo_ftplugin = "setl fo< tw< cole< cocu< fdm< fde< fdt<"
-setlocal formatoptions+=tcroql textwidth=78 cole=2 cocu=nc
+setlocal formatoptions+=tcroql textwidth=78 cole=2 cocu=nc foldmethod=expr
+let &l:foldexpr="getline(v:lnum)=~#'^=\\{70,}$' ? 1 : ".
+ \ "(getline(v:lnum+1)=~#'^=\\{70,}$' ? '<1' :".
+ \ "(getline(v:lnum)=~#'^-\\{70,}$' ? 2 : ".
+ \ "(getline(v:lnum+1)=~#'^-\\{70,}$' ? '<2' : ".
+ \ "'=')))"
+let &l:foldtext="v:folddashes.substitute(getline(v:foldstart+1), ".
+ \ "'\\v%( +\\*[^*]+\\*)* *$', '', '')"
let &cpo = s:cpo_save
unlet s:cpo_save
signature.asc
Description: This is a digitally signed message part.
