Tuesday, May 8, 2012

Re: Highlighting block of text

Success

:exec "highlight! Foo33 ctermbg=green guibg=green"
:call matchadd("Foo33", '\%>8c\%<21c\%>5l\%<14l.')
:call matchadd("Foo33", '\%>2c\%<11c\%>3l\%<6l.')

:exec "highlight! Foo34 ctermbg=white guibg=white"
:call matchadd("Foo34", '\%>18c\%<31c\%>5l\%<14l.')
:call matchadd("Foo34", '\%>12c\%<21c\%>3l\%<6l.')


:call clearmatches()

Tim, note that the leading and trailing '/' (patterns
generated by your example code) should not
be included. So, folks should modify your "Hi" function
to remove them if they wish to use matchadd().

Thanks all.

Richard


On 05/08/2012 04:14 PM, Tim Chase wrote:
> On 05/08/12 17:45, Gary Johnson wrote:
>> On 2012-05-08, Richard wrote:
>>> Well, I spoke too soon. What I wanted was to highlight
>>> multiple block with different colors *at the same time*
>>> Seems that match only works on a single pattern at a time.
>>
>> Use matchadd() instead.
>
> Hopefully made easier by the code I gave which builds up a regexp
> string that is then simply evaluated, which could instead just be
> passed to matchadd() with some appropriate highlighting-group
> designation.
>
> -tim
>
>

--
Quis custodiet ipsos custodes

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

No comments: