Created
September 15, 2012 03:20
-
-
Save dahu/3726230 to your computer and use it in GitHub Desktop.
Automatically highlight word under cursor if it appears more than once in the file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Clean-up of Swicher's Highlighter() | |
" Barry Arthur 2012-09-15 | |
function! Highlighter() | |
let word_cursor = escape(expand('<cword>'), ".*[]\\") | |
redir => output | |
silent! execute '%s/\<'.word_cursor.'\>//gen' | |
redir END | |
if output != "" | |
if str2nr(split(output)[0]) > 1 | |
execute printf('match IncSearch /\<%s\>/', word_cursor) | |
endif | |
normal `` | |
endif | |
endfunction | |
augroup Highlighter | |
au! | |
au CursorMoved * call Highlighter() | |
augroup END | |
set updatetime=300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment