I worked in NetBeans and liked this feature: when you place cursor in a variable name all occurences of the variable are highlighted. This is very useful for quick searching all occurences of the variable. Is it possible to add this behavior to Vim?
vimrc file by using vim editor. Add the text, “syntax on” anywhere in the file to enable syntax highlighting permanently for vim editor. Save and close the file by typing ':x'. For disabling the feature, just re-open .
With the default backslash leader key, pressing \l will highlight the line that currently contains the cursor. The mapping also sets mark l so you can type 'l to return to the highlighted line.
To enable Syntax Highlighting feature in VI editor, open the file called /etc/profile. Add the alias function to VI by pointing to VIM in /etc/profile file. This file is used to set alias functions globally. If you would like to set user specific aliases and functions, then you need to open the file .
This autocommand will do what you want:
:autocmd CursorMoved * exe printf('match IncSearch /\V\<%s\>/', escape(expand('<cword>'), '/\'))
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With