vim:aucmd: Reorder *Highlight* functions
Also improve their comments.
This commit is contained in:
@@ -57,23 +57,7 @@ augroup termdebug_bindings
|
|||||||
autocmd SourcePost termdebug.vim tnoremap <Esc> <C-\><C-n>
|
autocmd SourcePost termdebug.vim tnoremap <Esc> <C-\><C-n>
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Highlight word under cursor
|
" Highlight word under cursor in other places
|
||||||
function! ClearHighlights(what = s:CLEAR_HIGHS_ALL)
|
|
||||||
if and(a:what, s:CLEAR_HIGHS_CWORD) && exists('w:cword_match_id')
|
|
||||||
call matchdelete(w:cword_match_id)
|
|
||||||
unlet w:cword_match_id
|
|
||||||
unlet w:old_cword
|
|
||||||
endif
|
|
||||||
if and(a:what, s:CLEAR_HIGHS_VISUAL) && exists('w:visual_match_ids')
|
|
||||||
for l:pairs in w:visual_match_ids
|
|
||||||
let l:id = l:pairs[0]
|
|
||||||
let l:win = l:pairs[1]
|
|
||||||
call matchdelete(l:id, l:win)
|
|
||||||
endfor
|
|
||||||
unlet w:visual_match_ids
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! HighlightCurrentWord()
|
function! HighlightCurrentWord()
|
||||||
if exists('w:old_cword') && w:old_cword == expand('<cword>')
|
if exists('w:old_cword') && w:old_cword == expand('<cword>')
|
||||||
" Do not delete and readd the match if on the same word
|
" Do not delete and readd the match if on the same word
|
||||||
@@ -89,6 +73,7 @@ function! HighlightCurrentWord()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Highlight visual selection in other places
|
||||||
function! HighlightVisualSel()
|
function! HighlightVisualSel()
|
||||||
call ClearHighlights()
|
call ClearHighlights()
|
||||||
|
|
||||||
@@ -114,6 +99,23 @@ function! HighlightVisualSel()
|
|||||||
call setreg('"', l:old_reg, l:old_regtype)
|
call setreg('"', l:old_reg, l:old_regtype)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Clear the highlights of <cword> and visual selection
|
||||||
|
function! ClearHighlights(what = s:CLEAR_HIGHS_ALL)
|
||||||
|
if and(a:what, s:CLEAR_HIGHS_CWORD) && exists('w:cword_match_id')
|
||||||
|
call matchdelete(w:cword_match_id)
|
||||||
|
unlet w:cword_match_id
|
||||||
|
unlet w:old_cword
|
||||||
|
endif
|
||||||
|
if and(a:what, s:CLEAR_HIGHS_VISUAL) && exists('w:visual_match_ids')
|
||||||
|
for l:pairs in w:visual_match_ids
|
||||||
|
let l:id = l:pairs[0]
|
||||||
|
let l:win = l:pairs[1]
|
||||||
|
call matchdelete(l:id, l:win)
|
||||||
|
endfor
|
||||||
|
unlet w:visual_match_ids
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
augroup highlight_current
|
augroup highlight_current
|
||||||
au!
|
au!
|
||||||
au CursorMoved * if mode() == 'n' |
|
au CursorMoved * if mode() == 'n' |
|
||||||
|
|||||||
Reference in New Issue
Block a user