:match - ignore EOL ($)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

:match - ignore EOL ($)

Dominic Evans
Hi,

I use this autocmd

    autocmd BufEnter * hi rightMargin guibg=grey20 | match rightMargin /\%>80v/

To make the background slightly lighter on any text that extends past
80 columns. However I want it to ignore the line ending when
performing this match, as at the moment if text goes up to column 80
it shows a match on the (seemingly empty) space after this because
thats where the end of line occurs. Similarly on lines that do go
beyond this, the highlighted match extends one column further than
text is actually displayed.

I hope this is possible

Regards,
Dominic
Reply | Threaded
Open this post in threaded view
|

Re: :match - ignore EOL ($)

Tim Chase-2
>     autocmd BufEnter * hi rightMargin guibg=grey20 | match rightMargin /\%>80v/
>
> To make the background slightly lighter on any text that extends past
> 80 columns. However I want it to ignore the line ending when
> performing this match, as at the moment if text goes up to column 80
> it shows a match on the (seemingly empty) space after this because
> thats where the end of line occurs. Similarly on lines that do go
> beyond this, the highlighted match extends one column further than
> text is actually displayed.

Seems like you might want a regexp along the lines of

        \%>80c.\+

or alternatively

        \%81c.\+

By adding the ".\+" portion, you ensure that there's something
after that given column.  On lines that just go up to column 80,
there's nothing after it to match so you should be good.  I'm not
sure if you distinguished between \%80c and \%80v for a reason,
but using the \%c versions worked for highlighting everything
after column 80 for me.  YMMV :)  Additionally, I prefer to use
the \%c rather than the \%>c version, as when it's typed in a
regular search, with the ">" version, you find multiple hits for
the same result, whereas with the \%c version, it just finds one
hit.  It makes using n/N to find the next/previous match a little
less cumbersome.

HTH,

-tim






Reply | Threaded
Open this post in threaded view
|

Re: :match - ignore EOL ($)

Dominic Evans
Great, thanks very much. Im suprised I didn't think of adding .\+ - it
seems so simple when you put it like that :)

I didn't specifically choose \%80v over \%80c for any reason apart
from Bram used the virtual column method in :help :match so I just
copied that.

Cheers,
Dom

On 23/09/05, Tim Chase <[hidden email]> wrote:

> >     autocmd BufEnter * hi rightMargin guibg=grey20 | match rightMargin /\%>80v/
> >
> > To make the background slightly lighter on any text that extends past
> > 80 columns. However I want it to ignore the line ending when
> > performing this match, as at the moment if text goes up to column 80
> > it shows a match on the (seemingly empty) space after this because
> > thats where the end of line occurs. Similarly on lines that do go
> > beyond this, the highlighted match extends one column further than
> > text is actually displayed.
>
> Seems like you might want a regexp along the lines of
>
>         \%>80c.\+
>
> or alternatively
>
>         \%81c.\+
>
> By adding the ".\+" portion, you ensure that there's something
> after that given column.  On lines that just go up to column 80,
> there's nothing after it to match so you should be good.  I'm not
> sure if you distinguished between \%80c and \%80v for a reason,
> but using the \%c versions worked for highlighting everything
> after column 80 for me.  YMMV :)  Additionally, I prefer to use
> the \%c rather than the \%>c version, as when it's typed in a
> regular search, with the ">" version, you find multiple hits for
> the same result, whereas with the \%c version, it just finds one
> hit.  It makes using n/N to find the next/previous match a little
> less cumbersome.
>
> HTH,
>
> -tim
>
>
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

RE: :match - ignore EOL ($)

Keith W. Roberts
In reply to this post by Tim Chase-2
 

> -----Original Message-----
> From: Tim Chase [mailto:[hidden email]]
> Sent: Friday, September 23, 2005 5:52 AM
> To: Dominic Evans
> Cc: vim
> Subject: Re: :match - ignore EOL ($)
>
> >     autocmd BufEnter * hi rightMargin guibg=grey20 | match
> > rightMargin /\%>80v/
> > [snip]
>
> Seems like you might want a regexp along the lines of
>
> \%>80c.\+
>
> or alternatively
>
> \%81c.\+
>
> By adding the ".\+" portion, you ensure that there's something
> after that given column.  On lines that just go up to column 80,
> there's nothing after it to match so you should be good.  I'm not
> sure if you distinguished between \%80c and \%80v for a reason,
> but using the \%c versions worked for highlighting everything
> after column 80 for me.  YMMV :)  Additionally, I prefer to use
> the \%c rather than the \%>c version, as when it's typed in a
> regular search, with the ">" version, you find multiple hits for
> the same result, whereas with the \%c version, it just finds one
> hit.  It makes using n/N to find the next/previous match a little
> less cumbersome.

You can use \%c if you use 'et', because all the columns are real.  If you
use tabs I think the columns hilighted are different from \%v.

-Keith