Productivity Tips

IntelliJ Tips & Tricks

An IDE is so much more than an editor, yet people seem to compare one to another. The video by Hadi Hariri looks
at IntelliJ IDEA and gives you 42 tips and tricks that will make you a more efficient and productive developer (1 tip per minute).

Smart type completion after new

The SmartType code completion may be used after a "new" keyword to instantiate an object of the expected type. For example, type

Smart type completion after new

and press Ctrl+Shift+Space:

Smart type completion after new

Smart type completion

The SmartType code completion greatly helps to find methods and variables that are suitable in the current context by analyzing the expected type of the whole expression. For example, type and press Ctrl+Shift+Space:

Smart type completion

The SmartType completion also works after "return", in an assignment, in argument list of a method call and other places.

Smart type completion

Replace By when using lookup

When using Code Completion, you can accept the currently highlighted selection in the popup list with the Tab key.

Unlike accepting with the Enter key, the selected name will overwrite the rest of the name to the right of the caret. This can be especially useful for replacing one method or variable name with another.

Variable name completion

The CodeCompletion feature is able to suggest a name for a variable when you declare it. For example, you may start typing "private FileOutputStream" and press Ctrl+Space.

Variable name completion

You may customize name prefixes for local variables, parameters, instance and static fields in Options | IDE Settings | Code Style.

Finish lookup by special characters

When using Code Completion, you can accept the currently highlighted selection in the popup list with the period (.) character, the comma (,), the semicolon (';'), the space and other characters. The selected name is automatically entered in the editor followed by the entered character.

Class name completion

A special variant of the CodeCompletion feature invoked by Ctrl+Alt+Space allows you to complete the name of any class no matter if it was imported in the current file or not. If the class is not imported yet the import statement is generated automatically.

Class name completion

Basic code completion

The CodeCompletion feature allows you to quickly complete different kinds of statements in the code. For example, you may start typing a class name and press Ctrl+Space to complete it. When multiple choices are available, they are shown in the lookup list.

Basic code completion

Smart anonymous class instantiation

It's very easy to generate the whole anonymous implementation of some interface, for example, of some listener, by using the SmartType code completion. For example, you may type

           Component component;
             new <caret is here>

and press Ctrl+Shift+Space to see what happens.

Smart type casting

When you need to cast an expression value to the required type the SmartType code completion will help you. For example, type

          String s = (<caret is here>);

and press Ctrl+Shift+Space to see what happens.

to the top

Code Assistants

Comment/Uncomment line or block

You may comment/uncomment lines and blocks of code using Ctrl+NumPad / and Ctrl+Shift+NumPad /.

Ctrl+NumPad / comments/uncomments the current line or selected block with single line comments ("//..."). Ctrl+Shift+NumPad / encloses the selected block with a block comment ("/*...*/"). To uncomment a block comment press Ctrl+Shift+NumPad / anywhere inside it.

Override/Implement methods

You may easily override methods of the base class by pressing Ctrl+O (Code | Override Methods...).

To implement methods of the interfaces that the current class implements (or of the abstract base class), Ctrl+I (Code | Implement Methods...).

Quick JavaDoc in goto class or symbol

Shortcuts such as Ctrl+Q (Show Quick Javadoc), Ctrl+P (Show Parameter Info), Ctrl+B (Go to Declaration), Shift+F1 (External Javadoc) and others can be used not only in the editor, but in the code completion popup list as well.

Surround expression

When you want to catch exceptions thrown by some code fragment, select it in the editor, press Ctrl+Alt+T (Code | Surround with...) and choose "try/catch". It automatically generates catch blocks for all exceptions that are thrown inside the block. You may customize bodies of the generated catch blocks in Options | File Templates | Code tab. Use other items in the list to surround with other constructs.

Quick JavaDoc pop-up

To quickly see the Javadoc for the class or method used at the editor's caret, press Ctrl+Q (Show Quick Javadoc in the popup menu).

Browse external JavaDoc

To open your browser with Javadoc for the class or method used at the editor's caret, press Shift+F1 (External Javadoc in the popup menu).

You must have the path to your browser set in the "General" options (Options | IDE Settings) and paths to Javadoc-generated files added to your project (File | Project Properties) to use this feature.

Complete statement

Use Ctrl+Shift+Enter to complete a current statement such as if, do-while, try-catch, return (or a method call) into a syntactically correct construct.

Complete statement

to the top

Ant Support

Create property tag

You can start referring to an Ant property even if it is not defined yet. IntelliJ IDEA's intention action feature will suggest you to automatically create the necessary tag, without the need for you to leave your current editing location. Ant Property Intention

Create target tag

Refer to a non-existing target tag in your Ant-build file, and IntelliJ IDEA will suggest you to automatically create the corresponding tag. This intention action will even not make you change your current editing location. Ant Target Intention

Code Editing

Syntax aware selection

Ctrl+W (select word) in the editor selects a word at the caret and then selects expanding areas of the source code. For example, it may select a method name, then the expression that calls this method, then the whole statement, then the containing block, etc.

Editor incremental search

Use Alt+F3 (Search | Incremental Search) to quickly search in the editor.

Enter the word in the "Search for:" tool tip and use the arrow keys to search forward and back. Press Escape to exit.


Go to class or file

To open any class in the editor quickly, press Ctrl+N (Go to | Class...) and start typing the name of the class. Choose the class from a drop-down list that appears.

Go to class

The same way you can open non-java files in your project by using Ctrl+Shift+N (Go to | File...).

Go to implementation

To navigate to the implementation(s) of an abstract method, position the caret at its usage or its name in the declaration and press Ctrl+Alt+B.

Go to symbol

To open any particular java symbol like class, method or field in the editor quickly, press Ctrl+Alt+Shift+N (Go to | Symbol...) and start typing the symbol. Choose the symbol from a drop-down list that appears.

Go to symbol

Go to declaration

To navigate to the declaration of a class, method or variable used somewhere in the code, position the caret at the usage and press Ctrl+B. You may also click the mouse on usages with the Control key pressed to jump to declarations.

Go to declaration

Recent files popup

Ctrl+E (View | Recent Files) brings a popup list of recently viewed files. Choose the file and press Enter to open it.

Select in popup

To quickly select the currently edited element (class, file, method or field) in any view (Project View, Structure View or other) press Alt+F1 (View | Select in...).

Select in popup

File structure popup

You can quickly navigate in the currently edited file with Ctrl+F12 (View | File Structure Popup).

It shows the list of members of the current class. Select an element you want to navigate to and press the Enter key or the F4 key. To easily locate an item in the list, just start typing its name.

Using wildcards in go to class, file or symbol

For the pattern search in the Go to Class, Go to Symbol and Go to File popups, you can use * and space symbols. * stands for any symbol. Space at the end means the end of a pattern, and the preceding string will be considered not just a prefix but a whole pattern. The list of the suggested names will be reduced accordingly.

Using wildcards go to class, file or symbol

Using camel words prefixes in navigation popups

When in Go to Class, Go to Symbol, or Go to File popup, you can ease the search by filtering the lookup list with the help of the "camel words" prefixes.

Camel words prefixes in navigation popups

to the top

Speed search in trees

Speed search is available in all tree-views: just start typing characters in the tree to quickly locate an item.

Speed search in trees