VIM highlight variable under cursor like in netbeans?

This autocommand will do what you want: :autocmd CursorMoved * exe printf('match IncSearch /\/', expand('')) 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.

– UncleZeiv Jan 27 '10 at 17:07 @UncleZeiv: I'm not quite sure what you mean by errors – too much php Jan 27 '10 at 22:09 if I move the cursor on the end of a C-style comment (star followed by slash), I get E488: Trailing characters: match IncSearch /\, and I even have to press Enter before continuing, pretty annoying! I guess it should be escaped somehow and/or at least it would be ok to find a way to silence the warning. Great tip anyway.

– UncleZeiv Jan 28 '10 at 14:28 4 ok, easy enough, I just had to change it to :autocmd CursorMoved * silent! Exe printf('match IncSearch /\/', expand('')) – UncleZeiv Jan 29 '10 at 10:53.

If you set :set hlsearch to highlight all occurrences of a search pattern, and then use * or # to find occurrences of the word under your cursor, that will get you some way to what you want. However I think a syntax-aware variable highlighting is beyond the scope of VIM.

Your solution is great! The only problem is when I use * the cursor jumps over to the next search result. Isn't it possible to keep cursor on the current word?

– Meysam May 10 at 4:59.

You can highlight recognised names using the tags file as long as the tags file is generated with the --c-kinds=+l to ensure that it includes local variables. It could be done by parsing the C file in a little more detail and creating syntax regions for each function, but it is far from easy (and it would be incompatible with plugins like rainbow. Vim as Vim doesn't support overlapping regions).

On a related note, you may also be interested in my tag highlighting plugin available here. It will highlight local variables (if b:TypesFileIncludeLocals is set to 1 in the buffer open when running :UpdateTypesFile), but it doesn't deal with the scope of local variables. It does, however offer a lot more highlighting colour variations than the highlighting suggested in :help tag-highlight.

Note that your colour scheme will have to have highlights defined for lots of extra groups (e.g. GlobalVariable, LocalVariable, DefinedName etc) to take full advantage of it.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions