aboutsummaryrefslogtreecommitdiff
path: root/plugin/max-highlight-word-under-cursor.vim
blob: c6d6964a4ebdea19363f69985e01dc6c86af9ac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"=======================================================================================================================
" HIGHLIGHT_WORD_UNDER_CURSOR:
"=======================================================================================================================

let w:m1 = 0
function! HighlightWordUnderCursor()
    if(exists('w:m1') && w:m1 > 0)
        silent! call matchdelete(w:m1)
        let w:m1 = 0
    endif
    let l:currentword = escape(expand('<cword>'), '.')
    if(strlen(l:currentword) > 0)
        let w:m1=100
        if(match(expand('<cWORD>'), '^#\x\{6\}') == 0)
            exec 'highlight! CurrentColor guibg='.expand('<cWORD>')
            hi CurrentColor
            " silent! call matchadd('CurrentColor', escape(expand('<cWORD>'), '.'), -1, w:m1)
        else
            silent! call matchadd('Underline', '\<'.l:currentword.'\>', -1, w:m1)
        endif
    endif
endfunction

autocmd CursorHold,CursorHoldI * call HighlightWordUnderCursor()
..