IntelliJ navigate to next and previous highlighted variable

Intellij Idea

Intellij Idea Problem Overview


In IntelliJ 10.5 I have "Highlight usages of element at caret" enabled. When a variable/method/etc is selected, is there a way to move to the next and previous occurrence? I'm looking for the equivalent of Control-K in Eclipse.

Edit: Shortcut to navigate between highlighted usages simply moves to the next text occurrence, which is different than moving to the next occurrence of the variable/method/etc. If I have the variable foo selected, I want to navigate to the next occurrence of foo and not any piece of text called "foo" (including "foo" in comments, method names, etc).

Also, pressing F3 seems to be buggy. When I press F3, it sometimes searches using the previous searched text and not the currently highlighted text.

Intellij Idea Solutions


Solution 1 - Intellij Idea

  • F3 or shift+F3
  • ctrl+c, ctrl+f, enter or up and down arrows
  • ctrl+alt+F7

Added this in case people don't look at your edit.

Solution 2 - Intellij Idea

It's not currently possible, see my question: https://stackoverflow.com/questions/6198687/shortcut-to-navigate-between-highlighted-usages.

I even created an issue IDEA-70523 addressing this feature, please vote for it if you can't live without it like me :-).

Solution 3 - Intellij Idea

Install [Identifier Highlighter Reloaded][1] and use Alt + Shift + Up/Down (can be redefined in Keymap settings) :)

After you give it a shot and notice the 'hey, the highlight stays there after I move my cursor out of it' annoyance, consider upvoting [this issue][2] :)

[1]: https://plugins.jetbrains.com/idea/plugin/6318-identifier-highlighter-reloaded "Identifier Highlighter Reloaded" [2]: https://github.com/OlegYch/ih-reloaded/issues/3

Solution 4 - Intellij Idea

Vote this request up for make them implement the feature.

http://youtrack.jetbrains.com/issue/IDEA-59638

Solution 5 - Intellij Idea

I found something thay may more suite your needs : alt + mouse-wheel up/down.
It goes to previous / next occurrence of identifier under caret.

Shortcut name is "Go to next highlighted element usage".

Solution 6 - Intellij Idea

In the Mac OS, you can navigate to next highlighted usage by press control + option + up/down arrow.

Solution 7 - Intellij Idea

I usually do the following:

  1. Highlight the word
  2. Cmd + F (it will highlight all the matches in file)
  3. Cmd + G (next match)
  4. Cmd + Shift + G (previous match)

Solution 8 - Intellij Idea

I could not get any of IntelliJ's native options for Find Next/Previous to behave like in Eclipse. Find Word at Caret comes close, but it only allows you to slurp and find the next word, not previous.

Identifier Highlighter Reloaded also does not behave like Eclipse.

I wrote an IntelliJ plugin to reproduce the exact behavior as in Eclipse. You can find it here: https://plugins.jetbrains.com/plugin/10635-quick-find-plugin

Solution 9 - Intellij Idea

Look for next occurrence @ Keymap

Key mappings: next occurrence

^G = "select" the variable that you want to search for

[shift]⌘G = [previous]next occurrence of selected variable

All credits to @Igor Wojda for his comment in the accepted answer.

Solution 10 - Intellij Idea

(AFAIK, limiting search scope to only variable/method is not possible)

For text based match and quick jump:

  1. Simply place the cursor over the desired word to be searched
  2. Press Ctrl+F3
  3. For further down/up search, simply use F3/Shift+F3 respectively

Solution 11 - Intellij Idea

in Intellij shortcut for this action, it's not defined. but you can define it like this:

  • Ctrl+ Alt + S

  • search " highlighted usage"

  • then you can set a shortcut for that. enter image description here

Solution 12 - Intellij Idea

Ctrl+Alt+Up and Ctrl+Alt+Down navigates to the next and previous usages of a highlighted variable in IntelliJ.

I use this functionality of navigating to the next usage of a variable in a file by hot in Visual Studio all the time (Ctrl+Shift+Up and Ctrl+Shift+Down) and was looking for the equivalent in IntelliJ

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSteve KuoView Question on Stackoverflow
Solution 1 - Intellij IdeaTomView Answer on Stackoverflow
Solution 2 - Intellij IdeaTomasz NurkiewiczView Answer on Stackoverflow
Solution 3 - Intellij IdeaArtur GajowyView Answer on Stackoverflow
Solution 4 - Intellij IdeanucatusView Answer on Stackoverflow
Solution 5 - Intellij Ideaorion78frView Answer on Stackoverflow
Solution 6 - Intellij IdeaSteven ChouView Answer on Stackoverflow
Solution 7 - Intellij IdeawalvView Answer on Stackoverflow
Solution 8 - Intellij IdeaSeva SafrisView Answer on Stackoverflow
Solution 9 - Intellij IdealevelontView Answer on Stackoverflow
Solution 10 - Intellij IdeaKrishPrabakarView Answer on Stackoverflow
Solution 11 - Intellij Ideavahid ghasemiView Answer on Stackoverflow
Solution 12 - Intellij IdeaJohn EgbertView Answer on Stackoverflow