nnoremap h :call toggleWUC() function! s:updateWUC() if exists("b:hlwuc") if b:hlwuc > 1 call matchdelete(b:hlwuc) end end if exists("b:word_hl") let hl = b:word_hl else let hl = "Underlined" endif let l:str = "\\<".escape(expand(""), "\\")."\\>" let b:hlwuc = matchadd(hl, l:str) endfunc function! s:toggleWUC() augroup hlwuc if exists("b:hlwuc") autocmd! if b:hlwuc > 1 call matchdelete(b:hlwuc) end unlet b:hlwuc else autocmd CursorMoved call updateWUC() autocmd CursorMovedI call updateWUC() call updateWUC() endif augroup END redraw endfunction