vim:aucmd: Put often used <cword> into variable

This commit is contained in:
2024-04-03 13:11:22 +02:00
parent e84eaba7a2
commit 06b987afa8

View File

@@ -61,16 +61,17 @@ augroup END
" Highlight word under cursor in other places
function! HighlightCurrentWord()
if exists('w:old_cword') && w:old_cword == expand('<cword>')
let l:cword = expand('<cword>')
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 (expand('<cword>') != '')
let w:old_cword = expand('<cword>')
if (l:cword != '')
let w:old_cword = l:cword
let w:cword_match_id = matchadd(
\ 'CursorColumn',
\ '\V\<' . escape(expand('<cword>'), '/\') . '\>',
\ '\V\<' . escape(l:cword, '/\') . '\>',
\ -1)
endif
endfunction