IntelliJ: Iterate over focused word - intellij-idea

IntelliJ IDEA adequately highlights the word and its occurrences where the cursor position sits. I would like to know if shortcuts for navigating these highlighted words exists.

You can use CTRL+F3 to find the word at caret, and then use F3 and SHIFT+F3 to navigate between the occurrences.
[source]

Related

phpstorm search selection jumps to next occurrence

I use PhpStorm for years and have a habbit to select some word to find all its occurences in file.
Before phpstorm 10 when I select some word and press Ctrl+F, it just highlighted the word, cursor stayed on the word (and its occurences) and it showed search panel at the top of editor with matches count.
After upgrade to phpstorm 10 it became work in other way. Now when I select some word and press Ctrl+F it immediately jumps to next occerence of the selected word (it may be e.g. on the other end of the file).
That's very annoying - have to hit Back to move to the place where I started searching.
Does anybody know the reason of it? Maybe there is a way to disable such new behaviour?

Intelij: Highlist usages in plain text files?

Is there a setting in InteliJ to make it highlight usages of a word that is currently selected in plain text files similar to what Notepad and Sublime text editors do and what InteliJ does in java?
Help guide https://www.jetbrains.com/idea/help/highlighting-usages.html has Highlight usages of element at caret but that setting doesn't seem to change anything in plain text files.
To highlight all occurrences of a word in plain text, select the word and press Ctrl + F. This will open a search header filled with the selected word and all matches will be highlighted.
This is not exactly usages highlighting (since there is no real context in a plain text file), but it does what you want.
You can use Edit > Find > Highlight Usages in File Ctrl + Shift + F7.
This highlights all usages of selected text using the Find window.

How to go to next/previous occurrence in current editor tab?

In eclipse, you can go to the previous/next occurrence of the selected word by pressing ctrl+, / ctrl+..
What is the equivalent in IntelliJ IDEA?
The feature is called Find Word at Caret:
Search for a word at caret enables you to quickly find the exact match for the current word, without changing any search options. With the match once found, you can navigate between the occurrences of the term.
You can use Ctrl+F3 for that:
select a word at caret
hit Ctrl+F3 and then F3 or Shift+F3 to navigate to the
next/previous occurrence
Mac OS
Please note that there is no shortcut on Mac OS. You'd need to use Cmd+Shift+a and type "Find Word At Caret" ("find wo" should be enough) or on the main menu, choose Edit | Find | Find Word At Caret. Press Cmd+g to navigate to go to the next occurrence.
Separate Plugin
Or, try this plugin - it supports using Shift+Alt+Up and Shift+Alt+Down to navigate up and down to each identifier occurrence
To make this feature available by default please, vote for IDEA-59638
Use Ctrl+Shift+F7 to highlight the usages of some variable in the current file, then use F3 or Shift+F3 to navigate through the highlighted usages.
(It works in IntelliJ IDEA 2016.1.3)
Finding Word at Caret: Ctrl+F3:
Search for a word at caret enables you to quickly find the exact match for the current word, without changing any search options. With the match once found, you can navigate between the occurrences of the term.
Note that after it has found occurrences, it immediately goes to the first occurrence.
The functions for this are called Go to {next,previous} highlighted element usage and are available by default only via the menu Edit→Find. No key press is associated to this function by default. (IntelliJ IDEA 2018.3 (Community Edition))
You can set them to a specific key press in the keymap: File→Settings→Keymap→Main menu→Edit→Find and double click on the function you want to set.
EDIT:
IntelliJ IDEA 2021.3 (Community Edition): via main menu Edit→Find Usage→Next(Previous) Highlighted Usage
CMD + Shift + F7 to select all occurrences
than CMD + G to navigate forward
CMD + Shift + G to navigate backward

What is the shortcut to find next occurrence of a word in IntelliJ IDEA?

In Eclipse the keyboard shortcut to find next occurrence of a word in a file was Ctrl + k . It finds the occurrence of the selected word in a file one by one in a loop. What is the equivalent keyboard shortcut for IntelliJ IDEA? If not can we configure it some how?
First you'll have to highlight a symbol by pressing Ctrl+Shift+F7.
Then you just press F3 or Shift+F3 no navigate between the highlighted symbols.
When done you press Esc to exit the highlight searching.
It is all described on Highlightning Usages in IntelliJ Web Help.
Add selection for the next occurrence on Linux Alt+J
Finding Word at Caret: Ctrl+F3.
On Mac it's Command + G, but you can check what works for your OS by looking at Edit -> Find -> Find Next....
AFAIK you have to select the word in the search bar first.. So, Command + F and then Command + G to go to the next occurrence.
In Android Studio 1.4, apparently Mac OS default keyboard shortcuts for element next occurrence (vars, methods, etc) are
NEXT/FWD: Command+G
PREVIOUS: Shift+Command+G
I did try all the answers w/out success, and finally I looked it up in Prefs->Key Bindings
There are also hotkeys for navigating next/previous highlighted usages.
Several years ago they were Alt+Wheel down and Alt+Wheel up. Today they are not set by default.
You can find them in Keymap preferences with highlighted element usage search phrase.
Please consider using the Multiple Selections for this:
Select the term you want to lookup;
Use Alt+J / Shift+Alt+J (or Ctrl+G / Shift+Ctrl+G for Mac OS X) to select other occurrences.
It will work the same as Shift+F3, but it will select every next occurrences. I found this way much more conveniant, as you can choose to edit all the matching string or just move the cursor to edit the last selected one (←/→).
The Multiple Selections feature is available since IntelliJ IDEA 13.1 RC, and compete with Atom or Sublime Text similar feature.
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.
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
you can set shortcuts same as in eclipse by setting keymap value as eclipse.
Steps in intellij:
Go to setting in file
search for keymap
In the dropdown section set Eclipse
Now all your shortcuts are same as in eclipse.
For MAC:
First you'll have to highlight a symbol by pressing Command+Shift+F7.
Then for next occurrence Command+G or Command+Shift+G
On my Mac it is:
ctrl-l to find next occurrence
ctrl-shift-l to find previous occurrence
IntelliJ Keyboard Shortcuts
On Ubuntu:
Next occurrence of selected word: F3
To expand the question slightly, the method to display the next occurrence of a search term in the Find In Path pane, is to steer to it using the up/down arrows and then hit Enter.
Start by looking for all occurrence of the key (control + g)
Then use ( shift + command + g ) to find previous occurrence and ( command + g ) to find next occurrence.
For those who use IdeaVim plugin, there is another option.
Add these entries into .ideavimrc:
map <C-j> <Action>(GotoNextElementUnderCaretUsage)
map <C-k> <Action>(GotoPrevElementUnderCaretUsage)
This maps the navigation to the next/previous element under caret using ctrl+j/ctrl+k. Of course you can map it to something else, but this suggestion follows the standard navigation keys in vim.

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.
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.
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 :-).
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 :)
In the Mac OS, you can navigate to next highlighted usage by press control + option + up/down arrow.
Vote this request up for make them implement the feature.
http://youtrack.jetbrains.com/issue/IDEA-59638
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".
I usually do the following:
Highlight the word
Cmd + F (it will highlight all the matches in file)
Cmd + G (next match)
Cmd + Shift + G (previous match)
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
Look for next occurrence # Keymap
^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.
(AFAIK, limiting search scope to only variable/method is not possible)
For text based match and quick jump:
Simply place the cursor over the desired word to be searched
Press Ctrl+F3
For further down/up search, simply use
F3/Shift+F3 respectively
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.
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