diff --git a/vim/plugin/shame.vim b/vim/plugin/shame.vim index 04fed5d..9068dd6 100644 --- a/vim/plugin/shame.vim +++ b/vim/plugin/shame.vim @@ -629,40 +629,6 @@ digraph ss 223 command! HLProgress syntax match Comment /\_.*\ze\n.*\%#/ -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 - vnoremap g :call GrepOperator(visualmode()) nnoremap g :set operatorfunc=GrepOperatorg@ function! s:GrepOperator(type) diff --git a/vim/plugin/word-under-cursor.vim b/vim/plugin/word-under-cursor.vim new file mode 100644 index 0000000..56b9d4b --- /dev/null +++ b/vim/plugin/word-under-cursor.vim @@ -0,0 +1,33 @@ +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