I want to set different colors for odd and even lines in normal text
region, i.e., those lines that are not with any syntax defined.
How to do it?
--
Regards,
Yue Wu
Key Laboratory of Modern Chinese Medicines
Department of Traditional Chinese Medicine
China Pharmaceutical University
No.24, Tongjia Xiang Street, Nanjing 210009, China
I tried to dig up a link to this message, but it seems to
have fallen off the internet. Below is a thread on the
topic from ~4 years ago where Benji and Tony come up with a
solution that was elegant enough that I archived it in my
"good vim stuff I want to keep around" folder.
-tim
""""""""""""""""""""""""""""""""""""
Benji Fisher wrote:
[...]
>> I have not used syntax much either, but I decided to
>> test this. I think what you want is (two :hi lines
>> and) something like this:
>>
>> :syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines
skipnl
>> :syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines
skipnl
>>
>> In other words, drop "transparent" and add "skipnl". I
>> tested it with
>>
>> :syn clear
>>
>> first; I am not sure how well it will work without that.
>>
>> HTH --Benji Fisher
I agree about "skipnl".
Got it to work on text files, as follows (on W32)
---- ~/vimfiles/after/syntax/text.vim
hi default Oddlines ctermbg=grey guibg=#808080
hi default Evenlines cterm=NONE gui=NONE
syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl
syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl
---- $VIM/vimfiles/after/filetype.vim
augroup filetypedetect
au BufRead,BufNewFile *.txt setf text
augroup END
---- ~/vimfiles/colors/almost-default.vim
[...]
hi Oddlines ctermbg=yellow guibg=#FFFF99
hi Evenlines ctermbg=magenta guibg=#FFCCFF
[...]
Notes:
1. filetype.vim in an "after-directory" and with ":setf" to
avoid overriding already-detected "special" .txt files.
2. With "default" before the highlight name in the syntax
file (but not without it) the colors from the colorscheme
(invoked from the vimrc) are used. (Without a colorscheme,
the "default" colors from the syntax file are still used.)
3. Haven't succeeded (but haven't much tried) to make it
work for a more complex filetype with an already defined
syntax like HTML
4. After entering the above changes, Vim must be restarted
for them to take effect.
OK, enough for now, I'm taking a nap.
Best regards,
Tony.
> hi default Oddlines ctermbg=grey guibg=#808080
> hi default Evenlines cterm=NONE gui=NONE
> syn match Oddlines "^.*$" contains=ALL nextgroup=Evenlines skipnl
> syn match Evenlines "^.*$" contains=ALL nextgroup=Oddlines skipnl
Thank you, Tim, it works very well.
Maybe on the gmane or yahoo archive for the "old" Vim lists?
Now that I'm on Linux, I'm still using these (but under ~/.vim/ instead
of ~/vimfiles/ of course). I still haven't tried to apply this "pajama
highlighting" to anything other than text files. And if you don't like
the colours (the ctermbg ones are decidedly ;-) not the prettiest),
well, change them. In the meantime I've downloaded the CSApprox plugin
so even in konsole (but not of course on the Linux pure-text console
which is a "true" 8/16 colour terminal) I get "GUI" colours -- and as a
sidenote: when each of the red, green and blue components is a multiple
of 0x33, the colour exists "natively" on 256-colour terminals.
Best regards,
Tony.
--
Those who make peaceful revolution impossible will make violent
revolution inevitable.
-- John F. Kennedy
Having the original email saved (including the subject line), my
attempts to Google various excerpts of the exact text failed to
bring back the original message. No harm as I've reintroduced it
to teh intarwebs, but I've had little luck resurrecting such
"ancient" (gasp, 4 years old...that's a geologic age in internet
terms! :) emails despite knowing exact terms/phrases from the
message body.
Perhaps another's google-fu is stronger.
-tim
I Googled for
vim oddlines evenlines
and came up with
http://www.mail-archive.com/v...@vim.org/msg07010.html
which is your message from 2006:
Re: Shading alternating patterns.
Tim Chase
Tue, 10 Oct 2006 08:23:56 -0700
But there is no sign of the posts from Benji and Tony from February
of that year, even after clicking the "show more results" link. It
does look like the history cut-off is four years plus or minus a
couple of months.
Regards,
Gary
At this stage the goal is not to have very polished or feature-complete
plugins but to have something that can serve as example and a starting
point for people who want to develop for vim in python.
Sigh...can't count on the internet for _anything_ these days.
That's okay -- it's not like anything worth preserving was
happening more than four yea...ooh, look, a shiny object! :-)
-tim
Apparently Yahoo! itself keeps its archives longer than dedicated
"history archives" keepers. Here are a few threads on that subject,
including the one Tim saved:
10-Feb-2006 01:26 http://tech.groups.yahoo.com/group/vim/message/65679
10-Oct-2006 17:11 http://tech.groups.yahoo.com/group/vim/message/74391
20-Feb-2009 10:03 http://tech.groups.yahoo.com/group/vim/message/101663
Best regards,
Tony.
--
Experience is something you don't get until just after you need it.
-- Olivier
On So, 06 Jun 2010, Gary Johnson wrote:
> I Googled for
>
> vim oddlines evenlines
>
> and came up with
>
> http://www.mail-archive.com/v...@vim.org/msg07010.html
>
> which is your message from 2006:
>
> Re: Shading alternating patterns.
> Tim Chase
> Tue, 10 Oct 2006 08:23:56 -0700
>
> But there is no sign of the posts from Benji and Tony from February
> of that year, even after clicking the "show more results" link. It
> does look like the history cut-off is four years plus or minus a
> couple of months.
here it is at gmane:
http://thread.gmane.org/gmane.editors.vim/39403/focus=39403o
regards,
Christian
--
In der Jugend sind wir in der Regel sanguinisch, in sp�teren Jahren
cholerisch, nach der Ernte der Erfahrungen mehr oder weniger
melancholisch und im hohen Alter stumpf wie das Phlegma.
-- Karl Julius Weber
>
>
has some information from 2006
http://markmail.org/search/?q=vim++match+Oddlines
has February emails
http://markmail.org/search/?q=vim++match+Oddlines
> Having the original email saved (including the subject line), my
> attempts to Google various excerpts of the exact text failed to
> bring back the original message. No harm as I've reintroduced it
> to teh intarwebs, but I've had little luck resurrecting such
> "ancient" (gasp, 4 years old...that's a geologic age in internet
> terms! :) emails despite knowing exact terms/phrases from the
> message body.
I just googled for >>"despite knowing exact terms/phrases from"<< and
got yours. The quotes are _mandatory_ in these cases.
clemens
Yes, I had tried exact-phrase searching on an excerpt of the
original text (which I had in my local archive), but Google
yielded nothing. It turns out that searching individual archives
(such as Mark Mail or perhaps Gmane) can yield a deeper search
that what Google's results returned. My email (the excerpt from
which you quoted) was fresh enough that Google found it. I'm
guessing that the original email I tried to disinter was
sufficiently old that Google thought it wasn't worth
indexing/returning. However recent referencing of the thread will
likely have triggered reindexing of the page, making it reappear
in Google results.
-tim