From c60870019948c12cc369ec4106c2acfe73fdc69b Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Mon, 28 Oct 2024 21:09:28 +0100 Subject: [PATCH] vim:aucmd: Highlight selection on linewise v-mode I assumed that the selection will always be one character long when the ModeChanged event is triggered. This is not the case when entering linewise visual mode. Fixes: b0688da69e75 ("vim:aucmd: Do not highlight selection on ModeChanged") TODO: There are more ways of triggering ModeChanged to visual mode with a selection of more than one character (e.g. `[count]v`). --- .config/vim/vimrc.d/80-autocommands.vim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.config/vim/vimrc.d/80-autocommands.vim b/.config/vim/vimrc.d/80-autocommands.vim index ab7310f..5cc2ca6 100644 --- a/.config/vim/vimrc.d/80-autocommands.vim +++ b/.config/vim/vimrc.d/80-autocommands.vim @@ -173,11 +173,12 @@ augroup highlight_current au CursorMovedI * call HighlightCurrentWord() au WinLeave * call ClearHighlights() au ModeChanged [vV\x16]*:* call ClearHighlights(s:CLEAR_HIGHS_VISUAL) | call HighlightCurrentWord() - " 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) + " NOTE: HighlightVisualSel is not called when entering non-linewise visual + " mode as I rarely need one-character highlighting and I can work + " around by moving back and forth once. + " TODO: Fix for other ways of entering with a longer selection + au ModeChanged *:[v\x16]* call ClearHighlights(s:CLEAR_HIGHS_CWORD) + au ModeChanged *:V call ClearHighlights(s:CLEAR_HIGHS_CWORD) | call HighlightVisualSel() augroup END " When switching focus to another window, keep the cursor location underlined.