From 9db4b32f0250c51bc3f0cc62e7a6d67a4003600b Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 3 Apr 2024 13:26:42 +0200 Subject: [PATCH] vim:aucmd: Make highlighting toggleable --- .config/vim/vimrc.d/80-autocommands.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.config/vim/vimrc.d/80-autocommands.vim b/.config/vim/vimrc.d/80-autocommands.vim index 653fb11..73cf4a8 100644 --- a/.config/vim/vimrc.d/80-autocommands.vim +++ b/.config/vim/vimrc.d/80-autocommands.vim @@ -61,12 +61,18 @@ augroup END " Highlight word under cursor in other places function! HighlightCurrentWord() + if exists('w:disable_highlight_cword') + return + endif + let l:cword = expand('') if exists('w:old_cword') && w:old_cword == l:cword " Do not delete and readd the match if on the same word return endif + call ClearHighlights() + if (l:cword != '') let w:old_cword = l:cword let w:cword_match_id = matchadd( @@ -78,6 +84,10 @@ endfunction " Highlight visual selection in other places function! HighlightVisualSel() + if exists('w:disable_highlight_visual_sel') + return + endif + call ClearHighlights() let l:old_reg = getreg('"')