On Tue, Feb 23, 2010 at 2:30 AM, Ben Schmidt wrote:
> On 22/02/10 3:25 AM, Spencer Collyer wrote:
>>
>> On Fri, 19 Feb 2010 11:54:43 +0000, Paul wrote:
>>>
>>> When I have hls on, the searched words are highlighted. When I press
>>> n or # to jump through them, the page might scroll up or down and
>>> there could be a number of hit results shown. I sometimes have to
>>> wiggle the cursor left and right so I can see which one is currently
>>> being hovered over. Is there a way to colour differently each word
>>> when I jump through them with n and #?
>>>
>>
>> I don't know if it's possible to highlight the 'current' match
>> differently,
>
> No, I'm sure there isn't.

Nothing builtin, anyway.

>> but when this happens to me I generally just turn the
>> cursorline on (:set cursorline) to find which line the match is on, and
>> then it is normally obvious which is the match.
>
> You can also change the colour of the search highlighting so it is more
> different from your cursor colour. E.g.
>
> :hi Search guibg=darkgrey ctermbg=darkgrey
>
> might be better.

Or... If you wanted to be particularly industrious, you could probably
put together a vimscript that highlights the current match
differently.  Something like a CursorMoved autocmd that does
(completely untested)

    if exists("b:searchmatch")
        call matchdelete(b:searchmatch)
        unlet b:searchmatch
    endif

    let beg = searchpos(@/, 'cnW', line('.', 100)

    if beg != [ 0, 0 ]
        let end = searchpos(@/, 'cenW', line('.'), 100)
        if end != [ 0, 0 ]
            let b:searchmatch = matchadd('SomeColor',
printf('\%%%dl\%%%dc\_.*\%%%dl\%%%dc.', beg[0], beg[1], end[0],
end[1]))
        endif
    endif

I'm sure it's not perfect, but it could probably be made to work using
something like this, and the performance shouldn't be too terrible as
long as the lines aren't long.  You might even be able to prepend the
current cursor position to the start of the match pattern and get rid
of the 'beg' variable completely... I can't think of any time that
would be able to change a matching pattern to a non-matching one...

~Matt

-- 
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to