vim:aucmd: Improve highlighting on mode changes

When entering visual mode it does not really make sense to keep the
cword highlighting but it should restart automatically (i.e. without
CursorMoved) when leaving back out of visual mode.

About directly starting selection highlighting I am still unsure since I
rarely ever want to highlight only one character and it could decrease
performance.
This commit is contained in:
2024-03-24 16:39:56 +01:00
parent 6260c84f3a
commit 0006a778f9

View File

@@ -123,7 +123,8 @@ augroup highlight_current
\ endif
au CursorMovedI * call HighlightCurrentWord()
au WinLeave * call ClearHighlights()
au ModeChanged [vV\x16]*:* call ClearHighlights(s:CLEAR_HIGHS_VISUAL)
au ModeChanged [vV\x16]*:* call ClearHighlights(s:CLEAR_HIGHS_VISUAL) | call HighlightCurrentWord()
au ModeChanged *:[vV\x16]* call ClearHighlights(s:CLEAR_HIGHS_CWORD) | call HighlightVisualSel()
augroup END
" When switching focus to another window, keep the cursor location underlined.