Tim Chase wrote: > > Is there some way, perhaps through a syntax rule, or > > rules, to have Vim shade the background of *alternating* > > CSS definitions, assuming this file format? > > While I'm not sure the below will solve it, I've pasted in > some dialog from Benji Fisher and Tony Mechelynck (from back > in February of this year, which I saved as I thought it was > a nifty stunt) regarding the highlighting of alternate > *lines*. One might be able to use this as a foundation for > doing alternate CSS-rule-blocks: > > BF>> I have not used syntax much either, but I decided to test > BF>> this. I think what you want is (two :hi lines and) > BF>> something like this: > BF>> > BF>> :syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl > BF>> :syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl > BF>> > BF>> In other words, drop "transparent" and add "skipnl". I > BF>> tested it with > BF>> > BF>> :syn clear > BF>> > BF>> first; I am not sure how well it will work without that. > AM> > AM> I agree about "skipnl". > AM> > AM> Got it to work on text files, as follows (on W32) > AM> > AM> ---- ~/vimfiles/after/syntax/text.vim > AM> hi default Oddlines ctermbg=grey guibg=#808080 > AM> hi default Evenlines cterm=NONE gui=NONE > AM> > AM> syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl > AM> syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl > AM> > AM> ---- $VIM/vimfiles/after/filetype.vim > AM> augroup filetypedetect > AM> au BufRead,BufNewFile *.txt setf text > AM> augroup END > AM> > AM> ---- ~/vimfiles/colors/almost-default.vim > AM> [...] > AM> hi Oddlines ctermbg=yellow guibg=#FFFF99 > AM> hi Evenlines ctermbg=magenta guibg=#FFCCFF > AM> [...] > AM> > AM> Notes: > AM> 1. filetype.vim in an "after-directory" and with ":setf" > AM> to avoid overriding already-detected "special" .txt files. > AM> 2. With "default" before the highlight name in the syntax > AM> file (but not without it) the colors from the colorscheme > AM> (invoked from the vimrc) are used. (Without a colorscheme, > AM> the "default" colors from the syntax file are still used.) > AM> 3. Haven't succeeded (but haven't much tried) to make it > AM> work for a more complex filetype with an already defined > AM> syntax like HTML > AM> 4. After entering the above changes, Vim must be restarted > AM> for them to take effect. > > Hope it helps give you some grounds from which to find a > solution (even if I think Tony's a tad messed-in-the-head for choosing > yellow/magenta for alternating colors ;-) > > -tim
Thanks much, Tim, I will experiment with some of this and see what happens! Thanks also to Tony and Benji for coming up with this in the first place. -- Aaron "The Dude abides."