From 0006a778f97f039d26728832b95e63734a0dbe6e Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Sun, 24 Mar 2024 16:39:56 +0100 Subject: [PATCH] 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. --- .config/vim/vimrc.d/80-autocommands.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.config/vim/vimrc.d/80-autocommands.vim b/.config/vim/vimrc.d/80-autocommands.vim index 09e563b..f03844f 100644 --- a/.config/vim/vimrc.d/80-autocommands.vim +++ b/.config/vim/vimrc.d/80-autocommands.vim @@ -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.