Fix word under cursor updating on toggle
This commit is contained in:
parent
9d50868efa
commit
7a3be20539
1 changed files with 6 additions and 4 deletions
10
vimrc
10
vimrc
|
@ -736,6 +736,7 @@ digraph ss 223
|
||||||
command! HLProgress syntax match Comment /\_.*\ze\n.*\%#/
|
command! HLProgress syntax match Comment /\_.*\ze\n.*\%#/
|
||||||
|
|
||||||
nnoremap <leader>h :call <SID>toggleWUC()<CR>
|
nnoremap <leader>h :call <SID>toggleWUC()<CR>
|
||||||
|
|
||||||
function! s:updateWUC()
|
function! s:updateWUC()
|
||||||
if exists("b:hlwuc")
|
if exists("b:hlwuc")
|
||||||
if b:hlwuc > 1
|
if b:hlwuc > 1
|
||||||
|
@ -747,10 +748,10 @@ function! s:updateWUC()
|
||||||
else
|
else
|
||||||
let hl = "Underlined"
|
let hl = "Underlined"
|
||||||
endif
|
endif
|
||||||
let str = "\\<".escape(expand("<cword>"), "\\")."\\>"
|
let l:str = "\\<".escape(expand("<cword>"), "\\")."\\>"
|
||||||
let b:hlwuc = matchadd(hl, str)
|
let b:hlwuc = matchadd(hl, l:str)
|
||||||
"echom str
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function! s:toggleWUC()
|
function! s:toggleWUC()
|
||||||
augroup hlwuc
|
augroup hlwuc
|
||||||
if exists("b:hlwuc")
|
if exists("b:hlwuc")
|
||||||
|
@ -760,11 +761,12 @@ function! s:toggleWUC()
|
||||||
end
|
end
|
||||||
unlet b:hlwuc
|
unlet b:hlwuc
|
||||||
else
|
else
|
||||||
call <SID>updateWUC()
|
|
||||||
autocmd CursorMoved <buffer> call <SID>updateWUC()
|
autocmd CursorMoved <buffer> call <SID>updateWUC()
|
||||||
autocmd CursorMovedI <buffer> call <SID>updateWUC()
|
autocmd CursorMovedI <buffer> call <SID>updateWUC()
|
||||||
|
call <SID>updateWUC()
|
||||||
endif
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
|
redraw
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Autosave when vim loses focus :)
|
" Autosave when vim loses focus :)
|
||||||
|
|
Loading…
Reference in a new issue