Quantcast

How to highlight odd and even lines with different colors for normal text region.

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to highlight odd and even lines with different colors for normal text region.

Yue Wu
Hello list,

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

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Tim Chase
On 06/06/2010 07:23 AM, Yue Wu wrote:
 > 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.


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.




--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Yue Wu
On Sun, 06 Jun 2010 21:09:12 +0800, Tim Chase <[hidden email]>
wrote:

> 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.

--
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

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Tony Mechelynck
In reply to this post by Tim Chase
On 06/06/10 15:09, Tim Chase wrote:
> On 06/06/2010 07:23 AM, Yue Wu wrote:
>  > 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.
>
>
> I tried to dig up a link to this message, but it seems to
> have fallen off the internet.

Maybe on the gmane or yahoo archive for the "old" Vim lists?

> 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.

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

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Tim Chase
On 06/06/2010 11:00 AM, Tony Mechelynck wrote:
> On 06/06/10 15:09, Tim Chase wrote:
>> I tried to dig up a link to this message, but it seems to
>> have fallen off the internet.
>
> Maybe on the gmane or yahoo archive for the "old" Vim lists?

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




--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Gary Johnson-4
On 2010-06-06, Tim Chase wrote:

> On 06/06/2010 11:00 AM, Tony Mechelynck wrote:
> >On 06/06/10 15:09, Tim Chase wrote:
> >>I tried to dig up a link to this message, but it seems to
> >>have fallen off the internet.
> >
> >Maybe on the gmane or yahoo archive for the "old" Vim lists?
>
> 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 Googled for

    vim oddlines evenlines

and came up with

    http://www.mail-archive.com/vim@.../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

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Collection of vim scripts written in python

Andrei Kulakov

Hi, I made a collection of vim plugins with python:
http://lightbird.net/pysuite/  I need feedback! (they require vim
compiled with python).

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.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Tim Chase
In reply to this post by Gary Johnson-4
On 06/06/2010 02:41 PM, Gary Johnson wrote:

> I Googled for
>
>      vim oddlines evenlines
>
> and came up with
>
>      http://www.mail-archive.com/vim@.../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.

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


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Tony Mechelynck
In reply to this post by Gary Johnson-4
On 06/06/10 21:41, Gary Johnson wrote:

> On 2010-06-06, Tim Chase wrote:
>> On 06/06/2010 11:00 AM, Tony Mechelynck wrote:
>>> On 06/06/10 15:09, Tim Chase wrote:
>>>> I tried to dig up a link to this message, but it seems to
>>>> have fallen off the internet.
>>>
>>> Maybe on the gmane or yahoo archive for the "old" Vim lists?
>>
>> 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 Googled for
>
>      vim oddlines evenlines
>
> and came up with
>
>      http://www.mail-archive.com/vim@.../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
>

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

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Christian Brabandt
In reply to this post by Gary Johnson-4
Hi Gary!

On So, 06 Jun 2010, Gary Johnson wrote:

> I Googled for
>
>     vim oddlines evenlines
>
> and came up with
>
>     http://www.mail-archive.com/vim@.../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

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Reid Thompson
In reply to this post by Tim Chase
On Sun, 2010-06-06 at 14:19 -0500, Tim Chase wrote:
> On 06/06/2010 11:00 AM, Tony Mechelynck wrote:
> > On 06/06/10 15:09, Tim Chase wrote:
> >> I tried to dig up a link to this message, but it seems to
> >> have fallen off the internet.
> >
> > Maybe on the gmane or yahoo archive for the "old" Vim lists?
>

>
>

has some information from 2006
http://markmail.org/search/?q=vim++match+Oddlines


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to highlight odd and even lines with different colors for normal text region.

Reid Thompson
In reply to this post by Gary Johnson-4
On Sun, 2010-06-06 at 12:41 -0700, Gary Johnson wrote:

> 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.


has February emails
http://markmail.org/search/?q=vim++match+Oddlines

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

google exact (Re: How to highlight odd and even lines ...)

clemens fischer-3
In reply to this post by Tim Chase
On Sun-2010/06/06-21:19 Tim Chase wrote:

> 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

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: google exact (Re: How to highlight odd and even lines ...)

Tim Chase
On 06/20/2010 01:20 PM, clemens fischer wrote:
> On Sun-2010/06/06-21:19 Tim Chase wrote:
>> 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.

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


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Loading...