vim:aucmd: Clear highlights on exiting visual mode
When exiting visual mode I want to clear the highlights of the visual
selection. As this is done automatically now, <Esc> does not need to do
it (and i had problems with keys.vim executing ClearHighlights because
of the script variables).
This reverts commit b3f1a469db ("vim:keys: Clear highlights on
normal-mode Esc").
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
" vim: set foldmethod=marker:
|
" vim: set foldmethod=marker:
|
||||||
" Keybindings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
" Keybindings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" Clear all kinds of highlights when pressing Escape in normal mode
|
" Clear search result highlights when pressing Escape in normal mode
|
||||||
nnoremap <silent> <Esc> :nohlsearch <bar> call ClearHighlights()<CR><Esc>
|
nnoremap <silent> <Esc> :nohlsearch<CR><Esc>
|
||||||
|
|
||||||
" Indentation jump
|
" Indentation jump
|
||||||
" https://vim.fandom.com/wiki/Move_to_next/previous_line_with_same_indentation
|
" https://vim.fandom.com/wiki/Move_to_next/previous_line_with_same_indentation
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
" Autocommands """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
" Autocommands """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
|
" Bitfield for highlight_current augroup
|
||||||
|
const s:CLEAR_HIGHS_CWORD = 1
|
||||||
|
const s:CLEAR_HIGHS_VISUAL = 2
|
||||||
|
const s:CLEAR_HIGHS_ALL = 3
|
||||||
|
|
||||||
" Terminal
|
" Terminal
|
||||||
if (has('nvim'))
|
if (has('nvim'))
|
||||||
" Disable spellcheck
|
" Disable spellcheck
|
||||||
@@ -52,13 +58,13 @@ augroup termdebug_bindings
|
|||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Highlight word under cursor
|
" Highlight word under cursor
|
||||||
function! ClearHighlights()
|
function! ClearHighlights(what = s:CLEAR_HIGHS_ALL)
|
||||||
if exists('w:cword_match_id')
|
if and(a:what, s:CLEAR_HIGHS_CWORD) && exists('w:cword_match_id')
|
||||||
call matchdelete(w:cword_match_id)
|
call matchdelete(w:cword_match_id)
|
||||||
unlet w:cword_match_id
|
unlet w:cword_match_id
|
||||||
unlet w:old_cword
|
unlet w:old_cword
|
||||||
endif
|
endif
|
||||||
if exists('w:visual_match_ids')
|
if and(a:what, s:CLEAR_HIGHS_VISUAL) && exists('w:visual_match_ids')
|
||||||
for l:pairs in w:visual_match_ids
|
for l:pairs in w:visual_match_ids
|
||||||
let l:id = l:pairs[0]
|
let l:id = l:pairs[0]
|
||||||
let l:win = l:pairs[1]
|
let l:win = l:pairs[1]
|
||||||
@@ -117,6 +123,7 @@ augroup highlight_current
|
|||||||
\ endif
|
\ endif
|
||||||
au CursorMovedI * call HighlightCurrentWord()
|
au CursorMovedI * call HighlightCurrentWord()
|
||||||
au WinLeave * call ClearHighlights()
|
au WinLeave * call ClearHighlights()
|
||||||
|
au ModeChanged [vV\x16]*:* call ClearHighlights(s:CLEAR_HIGHS_VISUAL)
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" When switching focus to another window, keep the cursor location underlined.
|
" When switching focus to another window, keep the cursor location underlined.
|
||||||
|
|||||||
Reference in New Issue
Block a user