Hints and Tips
Switch between Tools & Editors
The Tool Windows are the views around the editor (to left, bottom and right). It’s possible to move these around to your preferred locations.
-
Use
alt-1
throughalt-9
(orcmd-1
throughalt-9
) to select the tool windows-
Press it twice and the tool window will hide itself; so can use to toggle
-
-
If in the Project Window (say) and hit enter on a file, then it will be shown in the editor, but (conveniently) the focus remains in the tool window. To switch to the editor, just press
Esc
.-
If in the Terminal Window, you’ll need to press
Shift-Esc
.
-
-
If on the editor and want to locate the file in (say) the Project Window, use
alt-F1
. -
To change the size of any tool window, use
ctrl-shift-arrow
Using these shortcuts you can easily toggle between the tool windows and the editor, without using the mouse. Peachy!
Navigating Around
For all of the following, you don’t need to type every letter, typing "ab" will actually search for ".a.*b.".
-
to open classes or files or methods that you know the name of:
-
ctrl-N
to open class -
ctrl-shift-N
to open a file -
(bit fiddly this)
ctrl-shift-alt-N
to search for any symbol.
-
-
open up dialog of recent files:
ctrl-E
-
search for any file:
shift-shift
Navigating around:
-
find callers of a method (the call hierarchy):
ctrl-alt-H
-
find subclasses or overrides:
ctrl-alt-B
-
find superclasses/interface/declaration:
ctrl-B
Viewing the structure (ie outline) of a class
* ctrl-F12
will pop-up a dialog showing all members
** hit ctrl-F12
again to also see inherited members
Editing
-
Extend selection using
ctrl-W
-
and contract it down again using
ctrl-shift-W
-
-
to duplicate a line, it’s
ctrl-D
-
if you have some text selected (or even some lines), it’ll actually duplicate the entire selection
-
-
to delete a line, it’s
ctrl-X
-
to move a line up or down:
shift-alt-up
andshift-alt-down
-
if you have selected several lines, it’ll move them all together
-
-
ctrl-shift-J
can be handy for joining lines together-
just hit enter to split them apart (even in string quotes; IntelliJ will "do the right thing")
-
Intentions and Code Completion
Massively useful is the "Intentions" popup; IntelliJ tries to guess what you might want to do. You can activate this using`alt-enter`, whenever you see a lightbulb/tooltip in the margin of the current line.
Code completion usually happens whenever you type '.'.
You can also use ctrl-space
to bring these up.
In certain circumstances (eg in methods0) you can also type ctrl-shift-space
to get a smart list of methods etc that you might want to call.
Can be useful.
Last, when invoking a method, use ctrl-P
to see the parameter types.
Refactoring
Loads of good stuff on the Refactor
menu; most used are:
-
Rename (
shift-F6
) -
Extract
-
method:
ctrl-alt-M
-
variable:
ctrl-alt-V
-
-
Inline method/variable:
ctrl-alt-N
-
Change signature
If you can’t remember all those shortcuts, just use ctrl-shift-alt-T
(might want to rebind that to something else!) and get a context-sensitive list of refactorings available for the currently selected object
Troubleshooting
When a Maven module is imported, IntelliJ generates its own project files, and the application is actually built from that.
Occasionally these don’t keep in sync (even if auto-import of Maven modules has been enabled).
To fix the issue, try:
-
go into PowerSafe mode, rebuild all from mvn command line, back into regular mode
-
reimport all modules
-
restart, invalidating caches
One thing worth knowing; IntelliJ actively scans the filesystem all the time.
It’s therefore (almost always) fine to build the app from the Maven command line; IntelliJ will detect the changes and keep in sync.
If you want to force that, use File > Synchronize
, ctrl-alt-Y
.