Move word-under-cursor code to separate file

This commit is contained in:
Talia 2020-08-17 14:53:55 +02:00
parent 230f3ee906
commit 71732691b2
2 changed files with 33 additions and 34 deletions

View file

@ -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)

View 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