I want to fold lines grouped at the top of file
and matching some pattern. I use foldmethod=expr.
But vim does not behave as expected.

In the testcase, /a/. In the testfile (2) below, I want first 3
lines (a\na\na\n) folded, and nothing else folded. But vim also folds
the last a\na\n lines. I think this is vim bug.

Yakov
-----------------------------
(1) the code

:set foldmethod=expr foldenable foldexpr=Foo()
function! Foo()
   echomsg '>>'.v:lnum.(v:lnum>1 ? ' prev='.foldlevel(v:lnum-1) : '')
   if v:lnum>1 && foldlevel(v:lnum-1) == 0
       return 0
   else
       return getline(v:lnum) =~ 'a'
   endif
endfun

(2) the testfile is
-------
a
a
a
b
b
b
a
a
-------

Reply via email to