IntelliJ navigate to next and previous highlighted variable - intellij-idea

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

Related

Select current line in intellij

Is there any way to select the whole line at caret in IntelliJ 15? I know you can select the current word (ctl + w), go to beginning/end of line but I can't find a current line selection feature.
Simply hit
ctrl+c
Note that for this to select the whole line, you need to ensure that nothing is already selected; otherwise it'll work as an usual "copy" command.
move caret to line
on Windows, press ctrl+shift+a .
This popup appears, where you find Select Line at Caret
for quick access, you can specify a shortcut in Settings
I would like to also add the following from JetBrains website. Because, that what i was looking for here, but no one mentioned it.
1- To select text from the current caret position to the beginning/end of
the current word:
Ctrl+Shift+Left, Ctrl+Shift+Right.
2- To select text from the caret
position to the beginning/end of the current line:
Double-click Ctrl and press Home/End
3- To select text from the current
caret position to the top/bottom of the screen:
Ctrl+Shift+Page Up, Ctrl+Shift+Page Down.
If none of the above are working, I suggest using end and home keys in combination with shift allowing you to select lines quickly.
Go to the end of the line and hit Ctrl+W. If you'll hit Ctrl+W at the beginning of the line it will select only one word.
Not a keyboard feature, but nice to use:
to select the whole row just click on row number on the left of the code.
In addition to that you can click and drag selection.
Moreover, you can doubleclick on the number of the first line of method which results selection of the whole method.

Visual Studio Code: Select each occurrence of find

I'm looking for a "select each occurrence of" something I'm trying to find. For example a file has a bunch of text that includes "abc", I type ctrl+f and type abc. I can either find the first one or the next one, but I would like to "multi-cursor" each one in the file.
I've already found the feature that lets me highlight text and ctrl+d to get the next that matches the selection, but if there's a hundred of these things - well that gets quite tiresome.
Ctrl+Shift+L Select all occurrences of current selection
editor.action.selectHighlights
Ctrl+F2 Select all occurrences of current word
editor.action.changeAll
Please refer for more information here.
Alt+Enter Select all occurrences of find match
editor.action.selectAllMatches
This has the added benefit of working with Regular Expression searches, since selecting occurrences of a word of a selection cannot leverage the Regex functionality.
I know this thread is here for a while now, but I think this will be helpful:
This thread on Github talks exactly about it:
https://github.com/microsoft/vscode/pull/5715
Summary:
Ctrl+F --> Open find widegt.
Alt+R --> Turn on regex mode.
Input search text --> Regex text or normal text.
Alt+Enter --> Select all matches.
Left arrow --> Ajust cursors.(Ignore this step if you don't want to edit the ---selected text.)
Edit text --> Do what you want.(Ignore this step if you don't want to edit the -selected text.)
Shift+Home --> Select modified text.(Ignore this step if you don't want to edit the selected text.)
Ctrl+C --> Copy selected text.
Ctrl+N --> Open a new tab.
Ctrl+V --> Paste.
well , basically the Ctrl+Shift+L will select all occurrences of word in the document BUT
there is some coool way to selecting them growingly:
if you hit Ctrl+d it will selects the second match , it you hit Ctrl+d again it will match the third one and so on ....
For Mach User:
COMMAND + Shift+ L Select all occurrences of the current selection
COMMAND + F2 Select all occurrences of the current word
For mac users::
Control + Command + G
^ + ⌘ + G
Ctrl+F2 is what worked for me for VSCode on Windows 10.
While Ctrl+Shift+L just opened some Language selector.
If you are searching in a single file, use simple search using Ctrl+F, then even if you close the search box, simply keep pressing F3 to go to next match and so on. F3 just repeats previous search and selects your next match.
On Mac:
Ctrl+F to open the find menu in top right:
Select the third option within the input and add the regex you want to match.
Ctrl+Shift+L to select all items that match.
Hope that helps!

In IDEA, how to jump to next occurrence of currently selected text?

In IDEA, when I have some text selected (e.g., a symbol), is there a way to quickly jump to the next occurrence of my current selection in the current file? I can do Ctrl+F, F3 and Esc but isn't there a quicker way, without the need to go through the find panel?
Edit: to make it clear, I am looking for a way to do this without the Find panel being open.
(One thing I noticed: the area behind scrollbar automatically indicates where else the current selection appears in the current file. Maybe there is some command to go to the next occurrence as indicated by the gutter?)
Select desired text and press CTRL+F3 to search for current selection, and then F3 for next ocurrence (or keep pressing CTRL+F3)
Try BrowseWordAtCaret, it is much better than CTRL+F3 which others suggested.
Description:
Allows to easily browse next/previous word at caret and highlight other appearances of selected word.
Usage: Browse with CTRL-ALT-UP, CTRL-ALT-DOWN (note: on default-keymap this shortcut is also for next/previous occurrence).
Once you have your search dialog open, use F3 to move to the next occurrence. Use Shift+F3 to move back an occurrence.

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.