Let's say I have the following code:
System.out.println(Math.PI);
Is there a plugin or some setting where I can hover over Math.PI and have IntelliJ tell me the value of the constant?
Press ctrl + q (or ctrl + j on mac) to activate the quick documentation action to see a documentation popup for this constant:
Also you could hover over PI with pressed ctrl:
Furthermore, you always can jump to the source code by ctrl + b.
It's much better to use View Definition feature.
By hitting Ctrl+Shift+I (if you're OSX user Option+Space) you will see the method, function, constant, variable definition in window popup.
Example with Objects#equals method:
Related
How can I show(unfold) the hidden(folded) code in IntelliJ IDEA, as shown in the picture below, just using keyboard without touching the mouse?
In IntelliJ IDEA you can use to following shortcuts to fold/unfold code blocks:
To fold and unfold CURRENT selected block of code:
CTRL+- and CTRL++ on Windows;
⌘ CMD+- and ⌘ CMD++ on Mac;
To fold and unfold ALL blocks of code:
CTRL+⇧ SHIFT+- and CTRL+⇧ SHIFT++ on Windows
⌘ CMD+⇧ SHIFT+- and ⌘ CMD+⇧ SHIFT++ on Mac.
By the way, in Settings → Editor → General → Code Folding you can specify the default folding behavior for a various situations (e.g., imports, one-line methods, inner classes, #SuppressWarnings annotations, array literals, generic constructors and many others):
And even after that your folding/unfolding hotkeys listed above will work as well.
To be sure which shortcuts are available go to settings > Keymap
then go to
Main Menu > Code > Folding
Expand
default on mac : cmd+
default on win : ctrl + numpad +
Collapse default on mac : cmd-
default on mac : cmd-
default on win : ctrl + numpad -
The only available option for your need (about import statements) is,
Move your pointer to (+) button on the left hand side of the statement so you can see the pointer changes to hand mark.
Then Ctrl + -
Find this for more info expanding/collapsing code. But this is more about blocks.
Easy to remember steps:
Press SHIFT twice
Type folding
Select Folding action
All options related to Expand and Collapse should be visible now (with keymaps)
Normally you would expect just hovering over a method it would show a popup of the return type.
How do you get this information in intellij ultimate?
Hit Ctrl + Q (or ⌃J on Mac) when cursor is on a method declaration or call. It will show you the pop-up you want. As a bonus: Ctrl + Shift + I will display method body as well in a pop-up.
You hover it and hold down CTRL in windows or CMD in Mac
Try Ctrl + Space for quick definitionAlso Ctrl + Shift + P may help
In intellij, Go to Help > Productivity Guide
you will find a list of useful shortcuts to increase productivity
Regarding, this question in mac Press option+command+V to get the list of names that you can choose
Ctrl+ J in mac for getting the documentation
Find screenshots for ease:-
Ctrl+Shift+P works great with extra bonus by highlighting relevant return expression (IntelliJ 2020.2.3 CE)
Hot key for that: Ctrl + Shift + P
Toolbar: "View->Type Info"
Used to know this, think its something like Ctrl + ??? + F11. Or something.
I have a class member/property that I would like to change the name of. Unfortunately it is sprinkled all over the class, some 100+ references to it. Throughout the various methods.
Eclipse has a shortcut that allows you to click on an identifier, hit the hotkey (whatever it is), and then modify the text composing the identifier. Then, once you click off of that text, it searches and replaces all references of the "old" identifier and replaces them with the new one.
I know I could just do a search & replace. I don't want that. I want the shortcut/hotkey. And its driving me crazy because I can't find it because I don't know what it's called!
Thanks to any Eclipse gurus that can help.
The shortcut combination is ALT + SHIFT + R.
CTRL+SHIFT+L list of all shortcuts.
The key combination is
Alt + Shift + R
The corresponding menu (and context menu) entry is
Refactor > Rename ...
I wanted to specify that the shortcut is Alt + Command + R if you're using Mac OS X.
PC
The shortcut for rename is:
Alt + Shift + r.
And the list of shortcuts will be displayed with:
Ctrl+Shift+L
Mac OS x
The shortcut defined for rename/refactoring will work:
option + ⌘ + R
The option for rename is:
F2
Both are shortcuts defined for Mac, open the Shortcuts List with
Shift + ⌘ + L:
Simply select the file and press F2. The rename option will open. Other option is ALt + Shift + R. But I prefer F2 is much easier way.
For renaming a file, the F2 works in all cases I've encountered.
However my experience shows that refactoring a class or a method can behave differently in different OS and desktop environments and that they may intercept key modifiers and thus render shortcuts ineffective.
However, eclipse is good at accessing its main menu from the keyboard. For instance, in plasma in linux (tested with eclipse 2019-09 and older) renaming is achieved pressing Alt-T, then releasing it and pressing N afterwards. The Alt-T effectively opens up the refactoring menu and the N orders eclipse to rename the selected element. Actually, the whole refactoring menu can be addressed in that manner, this achieving the goal with less friction.
For Mac, use the below keys
OPTION + COMMAND + R
How can I watch the contents of several variables (for example, TreeSet's) simultaneously? I can watch contents of one TreeSet, clicking on it in "Variables" window, but I have no idea how to do that for several variables.
You can use Expressions windows: while debugging, menu window -> Show View -> Expressions, then it has place to type variables of which you need to see contents
You can add a watchpoint for each variable you're interested in.
A watchpoint is a special breakpoint that stops the execution of an application whenever the value of a given expression changes, without specifying where it might occur. Unlike breakpoints (which are line-specific), watchpoints are associated with files. They take effect whenever a specified condition is true, regardless of when or where it occurred. You can set a watchpoint on a global variable by highlighting the variable in the editor, or by selecting it in the Outline view.
You can do so by these ways.
Add watchpoint and while debugging you can see variable in debugger window perspective under variable tab.
OR
Add System.out.println("variable = " + variable); and see in console.
And how about selecting the text you want to watch, and then using the shortcut "Ctrl + shift + I"
If I'm in an interface and pointing to a method name, what can I do to quickly go to the ONLY implementation of that method?
Using Eclipse 3.6.
F3 is the typical "go to implementation". For interfaces that go to the interface definition.
Instead use Ctrl + T to see all implementations of the interface definition. You can then easily go to the one you want with the arrow keys and Enter. I believe that the first one is automatically selected so that Ctrl-T + Enter will do what you need.
I just checked this on my Eclipse 3.6 install: Hold control (command on Mac), hover over the method name and select "Open Implementation".
You may assign a keyboard shortcut to this action by using Window > Preferences > General > Keys and searching for "Open Implementation".
In the keymap (General > Keys) search for "open implementation" and map it to whatever you want. I chose Ctrl + Shift + I. Make sure you select "Editing Java Source" in the When box. I tested it, and having the cursor over the method name and pressing Ctrl + Shift + I took me directly to the implementation instead of showing the hierarchy that you get with Ctrl + T.
Also you can see an answer to a nearly identical question for other options:
In eclipse, ctrl-click goes to the declaration of the method I clicked. For interfaces with one implementation, how can I just directly to that implementation?
If someone still need this information nowadays (Eclipse version 2022), to jump into interface method definition starting from an #Override method, now in Eclipse you can see on the left, next to the method signature, a little white triangle. By clicking on that you will jump to the implemented interface method. here an image of the little triangle
Oterwise, if you are on a interface method definition and you need to jump to one of the implementations, you must use CTRL+T shortcut to see the list of available implementations and than click on one of them.