tau-neutrino
tau-neutrino

Reputation: 3300

IntelliJ: How to auto-highlight variables like in Eclipse

My employer wants me to use IntelliJ for Java development. Previously, I've always used eclipse.

One of my favorite features in eclipse was being able to click on a variable, method parameter, class field, etc and see the usage of those variables highlighted throughout the class.

Is there a way to enable this feature in IntelliJ IDEA? I'm using Ultimate version 9.0.3.

Upvotes: 102

Views: 31013

Answers (4)

atom88
atom88

Reputation: 1554

Go into Settings->IDE Settings->Editor->Color Scheme->General

Make a copy of Dracula to something like MyOwnDracula (can't change the built in schema).

Find whatever you need to change, in this case it's "Identifier under caret" under the 'Code' section and change the colors for foreground and background to your liking.

Upvotes: 14

CrazyCoder
CrazyCoder

Reputation: 401877

  1. Go to File > Settings (Preferences on Mac)
  2. Go to Editor > Code Editing > Highlight on Caret Movement
  3. Enable Usages of element at caret.

Settings

Upvotes: 168

N Djel Okoye
N Djel Okoye

Reputation: 1080

Even though this is a question on how to highlight all variables, point one and two will answer that meanwhile point 3 will make you more productive and rename all variables simultaneously if you so choose to do so.

  1. With your cursor on an occurence.
  2. Do Ctrl+Shift+F7 to select all other occurrences.
  3. Then Shift + F6 to rename all occurences simultaneously.

Upvotes: 2

Mateus Viccari
Mateus Viccari

Reputation: 7699

I think Intellij does not do this by default for a reason. If you click in a symbol on your code, you can hit Ctrl+Shift+F7, then it will highlight (High visible, not just like the default underline) all occurences of the symbol. Good thing is, if you move out the cursor of that symbol, it will keep it highlighted wherever you go.

Tip: You can highlight how many different symbols you want at the same time.
Tip 2: F3 / Shift + F3 goes to the next / previous occurence respectively.

Upvotes: 18

Related Questions