On 3/1/07, Yakov Lerner <[EMAIL PROTECTED]> wrote:
On 3/1/07, MM <[EMAIL PROTECTED]> wrote:
> How do I create folds such that it starts at matched expression and
> ends at the line containing part of the matched expression.
> e.g i'd like to fold
>
> procedure xyz ( .....
> :
> :
> :
> :
> :
> end xyz;
>
Does this do what you want (untested):
let REGEX1='^procedure'
let REGEX2='^end'
set foldmethod=expr foldexpr=MyFoldLevel()
function! MyFoldLevel()
let line=getline(v:lnum)
if line =~ REGEX1
correction: this line should have been
if line =~ g:REGEX1
return "a1" " increase foldlevel
elseif line =~ REGEX2
Correction:
elseif line =~ g:REGEX2
return "s1" " decrease foldlevel
else
return '=' " foldlevel same as previous
endif
endfunc