Better search highlighting

This commit is contained in:
Andrew Tomaka 2014-05-09 01:16:01 -04:00
parent f9d8887aca
commit 5fd363e489

16
.vimrc
View file

@ -98,6 +98,10 @@ inoremap <Down> <NOP>
vnoremap > >gv
vnoremap < <gv
" Use better search highlighting
nnoremap <silent> n n:call HLNext(0.4)<cr>
nnoremap <silent> N N:call HLNext(0.4)<cr>
" Leaders (shortcuts)
let mapleader = ","
@ -197,6 +201,18 @@ function! RenameFile()
endif
endfunction
" Blink current search item - from Damian Conway 'More Instantly Better Vim'
function! HLNext (blinktime)
let [bufnum, lnum, col, off] = getpos('.')
let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
let target_pat = '\c\%#'.@/
let ring = matchadd('ErrorMsg', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(ring)
redraw
endfunction
" Set special case colors
function! SetColors()
highlight CursorLine cterm=NONE ctermbg=234