Matt Wozniski wrote:
> 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)
> ...

Totally bizarre, but it's looking sensational so far!

I have added a couple of trivial bits to finish Matt's code
and have done a very quick test. The SearchCurrent that I chose
suits my black-background color scheme.

The "let b:searchmatch =... end[1]))" is one line which
will wrap in this mail:

---start---
" Highlight current search hit so can easily see it if many hits.
highlight SearchCurrent guifg=black guibg=DarkOrange
augroup highlight_current
  autocmd!
  autocmd CursorMoved * silent call <SID>HighlightCurrent()
augroup END

function! s:HighlightCurrent()
  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('SearchCurrent', printf(
'\%%%dl\%%%dc\_.*\%%%dl\%%%dc.', beg[0], beg[1], end[0], end[1]))
    endif
  endif
endfunction
---end---

I am slowly tweaking the search tips on the wiki and will
probably add the above to some tip because I like to use a very
mild cursor and a prominent Search highlight, so I have suffered
from the OP's problem (can't see current hit if many on screen).

A problem with the above is that I now need an easy way to turn
off the highlight when I've finished searching (I will need to
add something to my mapping which does ":noh").

Recently I had picked an alternative, namely to press Ctrl-N to
toggle highlighting of the current line to help locate the
current hit:

:nnoremap <C-N> :setlocal cursorline!<CR>

John

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

Reply via email to