diff --git a/.config/vim/vimrc.d/80-autocommands.vim b/.config/vim/vimrc.d/80-autocommands.vim index add03bb..2fe9d9a 100644 --- a/.config/vim/vimrc.d/80-autocommands.vim +++ b/.config/vim/vimrc.d/80-autocommands.vim @@ -53,14 +53,18 @@ augroup END " Highlight word under cursor function! HighlightCurrentWord() + if exists('w:cword_match_id') + call matchdelete(w:cword_match_id) + unlet w:cword_match_id + endif if (expand('') != '') - exec 'match CursorColumn /\V\<' . escape(expand(''), '/\') . '\>/' + let w:cword_match_id = matchadd('CursorColumn', + \ '\V\<' . escape(expand(''), '/\') . '\>') endif endfunction augroup highlight_current_word au! - au CursorHold * call HighlightCurrentWord() - au CursorMoved * match + au CursorMoved * call HighlightCurrentWord() augroup END " Do not mark input from stdin as modified