vim:aucmd: Do not highlight selection on ModeChanged

Do not call HighlightVisualSel when the mode changes to visual mode, as
then the selection is still only one character long, which I rarely want
to highlight. If I do I can still move the cursor forth and back once.

TODO: Are there situation where ModeChanged is triggered and the
      selection is immediately longer than one char without triggering
      CursorMoved?
This commit is contained in:
2024-10-24 15:44:47 +02:00
parent 2a1346e74e
commit b0688da69e

View File

@@ -171,7 +171,11 @@ augroup highlight_current
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) | call HighlightCurrentWord() au ModeChanged [vV\x16]*:* call ClearHighlights(s:CLEAR_HIGHS_VISUAL) | call HighlightCurrentWord()
au ModeChanged *:[vV\x16]* call ClearHighlights(s:CLEAR_HIGHS_CWORD) | call HighlightVisualSel() " NOTE: HighlightVisualSel is not called here as I rarely need one-character
" highlighting and I can work around by moving back and forth once.
" TODO: are there situation where ModeChanged is triggered and the selection
" is immediately longer than one char without triggering CursorMoved?
au ModeChanged *:[vV\x16]* call ClearHighlights(s:CLEAR_HIGHS_CWORD)
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.