>> 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, i.e. {{{ stuff }}} (assuming foldmethod=marker) which is the only case where (foldlevel(i) != foldlevel(i-1)) && (foldlevel(i) != foldlevel(i+1)) 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?). 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 ), though it might be slow for large files (hard to say how many syntax lines with \%l will perform). Anyway, here is a snippet which will highlight folded lines based simply on foldlevel(): for level in range( 0, 9 ) exec 'syn clear level' . level exec 'hi clear level' . level endfor let last_level = 0 let start_syn = '' for linenr in range( 1, line("$") ) let level = foldlevel( linenr ) if level != last_level if start_syn != '' exec start_syn \ . '\%' . ( linenr - 1 ) . 'l.*' \ . '/' endif if level > 0 let start_syn = 'syn match level' . ( level % 10 ). ' /' \ . '\%' . linenr . 'l\_.*' else let start_syn = '' endif endif let last_level = level endfor