Highlight variable under cursor in Vim like in NetBeans

This autocommand will do what you want:

:autocmd CursorMoved * exe printf('match IncSearch /\V\<%s\>/', escape(expand('<cword>'), '/\'))

vi highlight current word

Edit: I have used the IncSearch highlight group in my example, but you can find other colours to use by running this command:

:so $VIMRUNTIME/syntax/hitest.vim

Leave a Comment