tags:

views:

64

answers:

2

Is it possible to have different set of colors for folds and subfolds, eg :

  • blue fg on grey bg for fold level 1 (default)
  • black fg on darkyellow bg for fold level 2
  • etc... (although going further down would seem a bit excessive)

Thanks

ThG

A: 

Hello.

From vim documentation:

COLORS                          *fold-colors*

The colors of a closed fold are set with the Folded group |hl-Folded|.  The
colors of the fold column are set with the FoldColumn group |hl-FoldColumn|.
Example to set the colors: >

        :highlight Folded guibg=grey guifg=blue
        :highlight FoldColumn guibg=darkgrey guifg=white

so you cannot easily do this. The best piece of advice I could give you is to set statusbar to display the current fold level if possible.

Benoit
I had seen that... but had not quite grasped the consequences. Thanks
ThG
+2  A: 

I have a simple patch to the Vim c code that lets you set this up pretty easily. Let me know if you want the patch to recompile Vim, or if you're on Windows I can send you a patched executable for Vim 7.2.

Herbert Sitz
Thanks for the answer, but I forgot to say it was for manual folding of plain text files. Thanks anyway. ThG
ThG
In this case, why not remap zf to also do a :call matchadd() and zd to do a `:call matchdelete()`?
Benoit
Benoit : I did not know this function and looked it up in the documentation. How do you, in that case, define the pattern ? More generally, how do you define in that function a pattern such as : FROM the beginning of the line TO a sequence of characters such as, eg, -:- ? (Could be used in a list of definitions to highlight the word to explain : Vim -:- an exacting text editor...) ThG
ThG
@ThG -- I think my patch would work for manual folds also. It involves using the 'foldexpr' option to set up function that returns the fold text. In the function you are able to change the highlight, and I believe the v:foldlevel variable is available to use to decide what highlight to apply, even for manual folding. If you have any interest I could confirm that.
Herbert Sitz
@Herbert Sitz : I have interest, but alas little competence. Anyhow, I am ready to try ... (Mac OS Terminal, Vim 7.3). As they (approx.) say in Mission impossible : "As always, should I fail in my mission, you may disavow any knowledge of my actions"
ThG
@ThG -- I did check and it does work with manual folding, but it sounds like you may have problems patching and recompiling Vim on OSX. If not, I'll be happy to give you the code. The coloring isn't exactly a trifle to me, since writing outlines is most of what I use Vim for, but it may not be worth it for you.
Herbert Sitz
@Herbert Sitz : I think my level in Vim is just not quite up to the task, yet. BTW it is not a trifling question for me either : in fact I wanted to manage a sort of personal Vim cookbook (items and definitions), with folds and subfolds, always opened during my Vim sessions, as an emergency toolkit... Thanks again
ThG