vim:autocmd: Match current word only if it exists
Check that the current word under the cursor exists (not empty) before adding it as match. Fix the disappearing of the welcome screen after a short time when opening vim without file as argument.
This commit is contained in:
@@ -52,8 +52,13 @@ augroup termdebug_bindings
|
||||
augroup END
|
||||
|
||||
" Highlight word under cursor
|
||||
function! HighlightCurrentWord()
|
||||
if (expand('<cword>') != '')
|
||||
exec 'match CursorColumn /\V\<' . escape(expand('<cword>'), '/\') . '\>/'
|
||||
endif
|
||||
endfunction
|
||||
augroup highlight_current_word
|
||||
au!
|
||||
au CursorHold * :exec 'match CursorColumn /\V\<' . escape(expand('<cword>'), '/\') . '\>/'
|
||||
au CursorMoved * :exec 'match'
|
||||
au CursorHold * call HighlightCurrentWord()
|
||||
au CursorMoved * match
|
||||
augroup END
|
||||
|
||||
Reference in New Issue
Block a user