Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable use highlighting in Intellij IDEA

One of the features I really like about Netbeans is that when you click on a variable, method, field etc. Netbeans shows you all the usages of this entity in the right hand bar as little bars of colour. Is there a way to get this behaviour in IntelliJ IDEA and if so, how do I turn it on? I haven't found anything in the settings or Google but I might be missing something!

like image 600
Michael Berry Avatar asked Feb 03 '11 23:02

Michael Berry


People also ask

How do you highlight variables?

Highlighting a variable or subfunction usage is easy, just click on any variable or subfunction name in the editor, and after a brief pause, all the usages of that variable or subfunction will be highlighted in light blue.

Can I highlight code in IntelliJ?

Enable semantic highlightingPress Ctrl+Alt+S to open the IDE settings and select Editor | Color Scheme | Language Defaults | Semantic highlighting. Select the Semantic highlighting checkbox and customize the color ranges if necessary.

How do I inspect a variable in IntelliJ?

IntelliJ IDEA allows you to inspect variables in a dedicated dialog. This is useful when you need to keep track of some variable (or the object whose reference it holds) and at the same time be able to navigate between frames and threads. Right-click a variable on the Variables tab and select Inspect.


2 Answers

Apart from enabling the "automatic highlight usages" setting described above, you can also invoke "highlight usages" manually, using the shortcut Ctrl+Shift+F7.

The benefits of using the "manual" highlight usages are:

  • You can highlight usages of multiple variables/methods/etc at the same time
  • You can remove highlighting for an individual element selectively, by invoking Ctrl+Shift+F7 again on that element
  • some users find it less distracting than "automatic highlight usage" - this is subjective or course
like image 43
Pakka Pakka Avatar answered Oct 11 '22 16:10

Pakka Pakka


file>settings or ctrl+alt+s (for windows) select editor from the list on the left and check Highlight usages of element at caret in the Highlight on Caret Movement section

like image 70
subhaze Avatar answered Oct 11 '22 16:10

subhaze