You're trying to express the fact that the interface
section ends one line before an implementation
line. Syntax regions (and apparently especially folding) work best when there's a definite region start and region end marker (like begin
and end
).
I've tried to make your example work by adding \n
to the pattern, but that also didn't work. I guess to get reliable folding, you need to switch from syntax-folding to a 'foldexpr'
, like this:
:setlocal foldmethod=expr foldexpr=getline(v:lnum)=='interface'\|\|getline(v:lnum)=='implementation'?'>1':'='