Steve Kuo
Steve Kuo

Reputation: 63104

IntelliJ navigate to next and previous highlighted variable

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.

Upvotes: 65

Views: 18438

Answers (13)

iulo
iulo

Reputation: 151

For Windows JetBrains Rider users, the only thing that worked for me was this Plugin:

BrowseWordAtCaret

Worked with JetBrains Rider 2024.3.5, Windows 11.

In Rider go to Settings (Ctrl + Alt + S) > Plugins > Marketplace > Search 'BrowseWordAtCaret' > Install.

After installing, check if it the plugin is enabled and then go to Settings > Editor > Appearance > scroll down to 'Browse Word at Caret' and check all the options.

(It didn't work without the step above for me)

Then use Ctrl + Alt + Up/Down in the editor to cycle between highlighted usages.

You can change the keymap in Settings > Keymap > Plugins > BrowseWordAtCaret

Upvotes: 0

John Egbert
John Egbert

Reputation: 5776

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

Upvotes: 0

Vahid
Vahid

Reputation: 83

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

Upvotes: 0

Steven Chou
Steven Chou

Reputation: 2215

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

Upvotes: 8

KrishPrabakar
KrishPrabakar

Reputation: 2842

(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

Upvotes: 0

levelont
levelont

Reputation: 626

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.

Upvotes: 0

Seva Safris
Seva Safris

Reputation: 502

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

Upvotes: 0

orion78fr
orion78fr

Reputation: 186

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".

Upvotes: 5

Artur Gajowy
Artur Gajowy

Reputation: 2038

Install Identifier Highlighter Reloaded 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 :)

Upvotes: 12

walv
walv

Reputation: 2878

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)

Upvotes: 1

nucatus
nucatus

Reputation: 2296

Vote this request up for make them implement the feature.

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

Upvotes: 3

Tom
Tom

Reputation: 1650

  • 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.

Upvotes: 45

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340883

It's not currently possible, see my question: 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 :-).

Upvotes: 38

Related Questions