Move word-under-cursor code to separate file
This commit is contained in:
parent
230f3ee906
commit
71732691b2
2 changed files with 33 additions and 34 deletions
|
@ -629,40 +629,6 @@ digraph ss 223
|
|||
|
||||
command! HLProgress syntax match Comment /\_.*\ze\n.*\%#/
|
||||
|
||||
nnoremap <leader>h :call <SID>toggleWUC()<CR>
|
||||
|
||||
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("<cword>"), "\\")."\\>"
|
||||
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 <buffer> call <SID>updateWUC()
|
||||
autocmd CursorMovedI <buffer> call <SID>updateWUC()
|
||||
call <SID>updateWUC()
|
||||
endif
|
||||
augroup END
|
||||
redraw
|
||||
endfunction
|
||||
|
||||
vnoremap <leader>g :<C-u>call <SID>GrepOperator(visualmode())<CR>
|
||||
nnoremap <leader>g :set operatorfunc=<SID>GrepOperator<CR>g@
|
||||
function! s:GrepOperator(type)
|
||||
|
|
33
vim/plugin/word-under-cursor.vim
Normal file
33
vim/plugin/word-under-cursor.vim
Normal file
|
@ -0,0 +1,33 @@
|
|||
nnoremap <leader>h :call <SID>toggleWUC()<CR>
|
||||
|
||||
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("<cword>"), "\\")."\\>"
|
||||
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 <buffer> call <SID>updateWUC()
|
||||
autocmd CursorMovedI <buffer> call <SID>updateWUC()
|
||||
call <SID>updateWUC()
|
||||
endif
|
||||
augroup END
|
||||
redraw
|
||||
endfunction
|
Loading…
Reference in a new issue