-rw-r--r-- start/self/plugin/autohighlight.vim
1 "------------------------------------------------------------------" 2 " Highlight all instances of word under cursor, when idle. 3 "------------------------------------------------------------------" 4 function! AutoHighlightToggle() 5 let @/ = '' 6 if exists('#auto_highlight') 7 au! auto_highlight 8 augroup! auto_highlight 9 setl updatetime=4000 10 echo 'Highlight current word: off' 11 return 0 12 else 13 augroup auto_highlight 14 au! 15 au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>' 16 augroup end 17 setl updatetime=500 18 echo 'Highlight current word: ON' 19 return 1 20 endif 21 endfunction 22 23 nnoremap <bar> :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR> 24