Eric Arnold wrote:
>
>>>> On 5/5/06, Suresh Govindachar wrote:
>>>>>
>>>>> I would like to color a file as follows:
>>>>>
>>>>> Everything is "normal" except for lines whose
>>>>> foldlevel is different from the foldlevel of both
>>>>> the line above and the line below. For such lines,
>>>>> the color should be Color_N where N is
>>>>> (foldlevel/2)%7 (wherein Color_0 could be red,
>>>>> Color_1 could be blue etc.).
>>>>>
>
> I don't understand. This would mark only folds of a single line
Yes
[...]
> I'm also wondering if you meant to change the color only every
> other fold level (i.e. color is (foldlevel/2)%7 (7 is the number
> of colors available?).
No, color (not every other) but every fold of single line, but
use same color twice.
> As to folding readonly files, it would be possible to create a
> syntax based on the line numbers of the folded lines (i.e. with
> \%l )
[...]
Thanks for pointing out \%l -- it enabled me to avoid markers.
Here's what I came up with (written in multiple lines to make
it easy to read):
%g/./let i = line('.') |
if( (foldlevel(i) != foldlevel(i-1))
&& (foldlevel(i) != foldlevel(i+1)))|
exec 'syn match level'.foldlevel(i)/2 .
' /\%'.i.'l.*/ contains=marker,todoo'|
endif|nohls
with example of highlight for levelN on dark background being:
hi def level1 ctermfg=3 cterm=bold gui=bold guifg=lightblue term=reverse
--Suresh