Avoid automatically going to single usage on ctrl+click in Intellij - intellij-idea

In IntelliJ by default ctrl+click does Show Usages and depending on the number of usages found either goes to the usage (one result) or opens a list (two or more results).
Is there any way to always show the list even on single results?

Related

How to undo in Intellij IDEA replace in files?

In intellij 2022.1, I use Ctrl+Shift+R to bring up the Replace in Files window - it shows 100+ matches in 40+ files. The search string and the replace string differ in only one character, for example: this.bar.is.fooed and this.barf.is.fooed. I only need to replace certain instances based on nearby text.
I'm in the groove, clicking the Replace button, checking the next entry, clicking, checking, ... and thinking my brain can keep things straight (it can't; neither can yours:-) I'm halfway through when I realize the last few replaces were wrong.
How can I undo them? Ctrl+Z is grayed out. This related SO question doesn't say and neither does the JetBrains documentation!
Use Local History to revert the changes.
Undo/redo is not supported for Replace dialog, vote for the related request.

IntelliJ IDEA equivalent of Edit.GoToNext/PrevLocation

In Visual Studio 2019 I can use Find in Files to find some text in my code. Then I can use Edit.GoToNextLocation and Edit.GoToPrevLocation to move through the matches. (I have them mapped to Ctrl-N and Ctrl-Shift-N.) This allows me to jump from location to location and edit as necessary without having to use the mouse.
How can I do the same thing in IntelliJ IDEA?
There are many ways, I suggest you get familiar with "Action" shortcut (control+shift+A) and "type" what you want, see if there's an action and what shortcut (if any) it has.
For e.g.:
Get also familiar with "Bookmarks". (Control Tab, Double Shift are also good) Control-E (recent is nice) think all these you can "type" to search in them as well and narrow the results using fuzzy search (aka: type TM for "TimeManager" for example). You get the idea.
I think I found it!
IntelliJ IDEA appears to have a Next Occurrence command that does what I want.
It seems that to get a navigable list of found results, I need to do Find in Path... followed by Open in Find Window (Ctrl-Enter). Then Next Occurrence and Previous Occurrence (not to be confused with Move to Next Occurrence and Move to Previous Occurrence!) take me through the various places.
In IntelliJ IDEA it doesn't loop back to the first result like Visual Studio does, but I can live with that.
I do wish it would go straight to the Find Window instead of me having to tell it to.

Load custom location list in IntelliJ

In IntelliJ IDEA, when I press Alt-F7, it loads a list of usages of whatever I'm highlighting; it's a nice list feature that allows me to jump around various lines of code that are of interest.
I'm interested in doing that in a more abstract way. If I write a script that analyzes code and spits out a list of files and line numbers, I'd like to be able to navigate those in a similar fashion. Similar to Vim's quickfix feature (and I'm sure other text editors support this sort of thing).
Example output:
project-a/src/main/java/com/example/Foo.java:34
project-a/src/main/java/com/example/Foo.java:66
project-b/src/main/java/com/example/Bar.java:198
Does IntelliJ support loading this as a list of locations? If so, how?
The case in particular I have is that I wrote a script that looks for throw statements inside a catch block that do not reference the caught exception. So I can output the locations any way that IntelliJ likes to see them.
You can set up an external tool that will run your script, and configure an output filter to turn its output into clickable links. It won't look like the usages view, but it's the simplest thing you can do.
Alternatively, you can convert your script into an IntelliJ inspection, which will let you see its results directly as you're editing code, or run Analyze | Inspect Code to get a summary of the results across your project.

How to select nth item from a context menu i Intellij?

E.g. when selecting one of completions suggested by Intellij when typing code. Using arrow keys requires relocation of right hand and simply continuing to write is slow, too.
Is there a faster way?

What is the principle by which keyboard shortcuts selected in IntelliJ IDEA?

There are lots of useful functions of Intellij IDEA and for many of them there are keyboard shortcuts.
But remembering shortcuts may be difficult, at least for me.
Are there some consistent guiding principles by which these shortcuts were selected by designers? I believe learning such principles would be helpful to memorize shortcuts itself.
I think that the closest answer you're going to get is "it depends". Some shortcuts are obviously chosen, because the keybinding describes what the shortcut does, for example ⌘+O means open, not only in IntelliJ but in many places throughout OS X.
Some shortcuts probably don't have any kind of such semantic meaning, such as Alt+Enter and are chosen because they are very frequently used and the placement of the keys relative to each other is comfortable.
Other keyboard shortcuts with similar purpose have the same starting sequence of keys. For instance the extract refactoring shortcuts, which are as follows:
⌘+Alt+M - extract method
⌘+Alt+C - extract constant
⌘+Alt+V - extract variable
⌘+Alt+F - extract field
⌘+Alt+P - extract parameter
So in such case you only need to remember that if you want to extract something, you press ⌘+Alt and the first letter of what you want to extract.
That being said, I don't believe that the way to learning the keybindings is memorizing them, but using them. If you use one keybinding multiple times, over the time you will memorize it. You can help this process for instance by locating the action you want to perform in the menu, but instead of clicking it look at the keyboard shortcut next to it and press it. Or find the action using ⌘+Shift+A, look at the shortcut and use it.
There are even plugins, which can help you with this, for instance Key Promoter which you can install via Settings/Plugins/Browse Repositories. This plugin shows you shortcut you can use when you invoke some actions by clicking it in menu, etc. It also shows you how many times you've used this action in such a way instead of using the corresponding shortcut.