Thursday, March 4, 2010

Re: Two search buffers, different color highlights

corykendall wrote:
> Anyone have a plugin or manual setup which lets you do this? I'm
> thinking the way I use '*' to match the current word, it would be
> great if I could have '&' search for a different word, but keep the
> first in the search buffer. The new word could be highlighted a
> different color.

Well, you could hack something with the ":match" and ":2match"
family of commands to colorize the 2nd item, though n/N won't
work for finding the next/previous match on them. Or you could
map "#" and "*" to stash the current search in the :match item
and then perform the search. Something like this untested:

:nnoremap * :exec 'match Error /'.escape(@/, '/').'/'<cr>*
:nnoremap # :exec 'match Error /'.escape(@/, '/').'/'<cr>#

You might be able to use "expand('<cword>')" if you prefer the
other direction (as you suggest using the "&" search for a
different word). Adjust Error to be whatever syntax highlighting
group you like. I just happen to remember "Error" off the top of
my head and it's easy to type/see. ;-)

-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

No comments: