IntelliJ IDEA 2019.3 Help

Discover IntelliJ IDEA

IntelliJ IDEA helps you stay productive with an array of features for efficient development. This topic provides an overview of common and useful tips to get started.

User interface

You can invoke almost any action without leaving the IntelliJ IDEA Editor, which means you can have more screen space because auxiliary controls like toolbars and windows are hidden.

IntelliJ IDEA interface

When you use a shortcut to access any tool window, the input focus and context moves to this window. To move the focus back to the editor, press Escape. The following table lists default tool windows and their corresponding shortcuts:

Tool Window

Shortcut

Project

Alt+1

Version Control

Alt+9

Run

Alt+4

Debug

Alt+5

Terminal

Alt+F12

Editor

Escape

To focus on your code, try Distraction Free Mode, which removes all toolbars, tool windows, and editor tabs. To switch to this mode, from the main menu select View | Appearance | Enter Distraction Free Mode.

You can also hide all tool windows by pressing Ctrl+Shift+F12 and then restore the layout by pressing this shortcut again.

The Navigation Bar is a compact alternative to the Project Tool Window. To access the Navigation Bar, press Alt+Home.

The Navigation Bar

Most components in IntelliJ IDEA, including tool windows and pop-ups, provide speed search: start typing anything to filter the list or navigate to a particular item by the typed search query.

Speed search

For more information, see Overview of the user interface and Working with tool windows.

Editor shortcuts

The following table lists some useful shortcuts related to editing your code:

Action

Description

Move the current line of code

Ctrl+Shift+Up Ctrl+Shift+Down

Duplicate a line of code

Ctrl+D

Remove a line of code

Ctrl+Y

Comment or uncomment a line of code

Ctrl+/

Comment a block of code

Ctrl+Shift+/

Find in the currently opened file

Ctrl+F

Find and replace in the current file

Ctrl+R

Next occurrence

F3

Previous occurrence

Shift+F3

Navigate between opened tabs

Alt+Right Alt+Left

Navigate back/forward

Ctrl+Alt+Left Ctrl+Alt+Right

Expand or collapse a code block in the editor

Ctrl+NumPad Plus Ctrl+NumPad -

Create new...

Alt+Insert

Surround with

Ctrl+Alt+T

Highlight usages of a symbol

Ctrl+F7

To expand or shrink the selection based on language constructs, press Ctrl+W and Ctrl+Shift+W.

You can select more than one piece of code at a time. To add the next occurrence of your current selection, press Alt+J. To remove an occurrence, press Shift+Alt+J.

For more information, see Editor basics.

Code completion

Press Ctrl+Space to invoke Basic Completion for variables, types, methods, expressions, and so on. Press Ctrl+Space twice to show more suggestions, including private members and non-imported static members.

Press Ctrl+Shift+Space to invoke Smart Completion, which is aware of the expected type and data flow, and shows suggestions relevant to the context. Press Ctrl+Shift+Space twice to show more suggestions, including chains.

Press Ctrl+Shift+Enter to invoke Statement Completion, which adds the missing parentheses, brackets, braces, and other necessary formatting.

Press Ctrl+P to see the suggested parameters for a method or constructor. IntelliJ IDEA shows the parameter info for each overloaded method or constructor, and highlights the best match for the parameters already typed.

Use Postfix Completion to transform an existing expression with a postfix that you type after a dot.

For more information, see Code completion.

Recent files

Most of the time you work with a finite set of files, and need to switch between them quickly. A real time-saver here is an action called Recent Files invoked by pressing Ctrl+E. By default, the focus is on the last accessed file. Note that you can also open any tool window through this action:

Recent Files popup

Navigate to Class is available by pressing Ctrl+N and supports sophisticated expressions, including camel humps, paths, line navigate to, middle name matching, and many more. If you call it twice, it shows you the results out of the project classes.

Navigate to File works similarly by pressing Ctrl+Shift+N, but is used for files and folders. To navigate to a folder, end your expression with the Slash character.

Navigate to Symbol is available by pressing Ctrl+Shift+Alt+N and allows you to find a method or a field by its name.

Structure

When you are not switching between files, you are most probably navigating within a file. The simplest way to do it is to press Ctrl+F12. The popup shows you the structure of a file, and allows you to quickly navigate to any of them:

Structure tool window

Select in

If you need to open a file in a particular tool window (or Finder/Explorer), you can do so via the Select In action by pressing Alt+F1:

Select in popup

Navigation shortcuts include:

Action

Shortcut

Search everywhere

Double Shift

Navigate to class

Ctrl+N

Navigate to file

Ctrl+Shift+N

Navigate to symbol

Ctrl+Shift+Alt+N

Recent files

Ctrl+E

File structure

Ctrl+F12

Select in

Alt+F1

Navigate to declaration

Ctrl+B

Navigate to type hierarchy

Ctrl+H

Show UML popup

Ctrl+Alt+U

For more details, refer to Source code navigation.

Quick pop-ups

Quick Popup are helpful for checking additional information related to the symbol at the caret. Below is a list of pop-ups you should know if you want to be more productive:

Action

Shortcut

Documentation

Ctrl+Q

Quick definition

Ctrl+Shift+I

Show usages

Ctrl+Alt+F7

Show implementation

Ctrl+Alt+B

Refactoring basics

IntelliJ IDEA offers a comprehensive set of automated code refactorings that lead to significant productivity gains when used correctly. Firstly, don't bother selecting anything before you apply a refactoring. IntelliJ IDEA is smart enough to figure out what statement you're going to refactor, and only asks for confirmation if several choices are possible.

Action

Shortcut

Rename

Shift+F6

Extract variable

Ctrl+Alt+V

Extract field

Ctrl+Alt+F

Extract a constant

Ctrl+Alt+C

Extract a method

Ctrl+Alt+M

Extract a parameter

Ctrl+Alt+P

Inline

Ctrl+Alt+N

Copy

F5

Move

F6

Refactor this

Ctrl+Shift+Alt+T

For more details, refer to Refactoring code.

Finding usages

Find Usages helps you quickly find all pieces of code referencing the symbol at the caret (cursor), no matter if the symbol is a class, method, field, parameter, or another statement. Just press Alt+F7 and get a list of references grouped by usage type, module, and file.

If you want to set custom options for the Find Usages algorithm, press Ctrl+Shift+Alt+F7, or click the first button on the right panel with search results.

If what you're looking for is plain text, use Find in Path by pressing Ctrl+Shift+F.

For more details, refer to Search for usages.

Inspections

Inspections are built-in static code analysis tools that help you find probable bugs, locate dead code, detect performance issues, and improve the overall code structure.

Most inspections not only tell you where a problem is, but also provide quick fixes to deal with it right away. Press Alt+Enter to choose a quick-fix.

Inspections that are too complex to be run on-the-fly are available when you perform code analysis for the entire project. You can do this in one of the following two ways: by selecting Analyze | Inspect Code from the main menu, or by selecting Analyze | Run Inspection by Name to run an inspection by its name.

Note that while inspections provide quick-fixes for code that has potential problems, intentions help you apply automatic changes to code that is correct. To get a list of intentions applicable to the code at the caret, press Alt+Enter.

For more details, refer to Code inspections.

Code style and formatting

IntelliJ IDEA automatically applies a code style you've configured in the Code Style settings as you edit, and in most cases you don't need to call the Reformat Code action explicitly.

Useful formatting shortcuts:

Action

Shortcut

Reformat code

Ctrl+Alt+L

Auto-indent lines

Ctrl+Alt+I

Optimize imports

Ctrl+Alt+O

Note that by default, IntelliJ IDEA uses regular spaces for indents instead of tabs. If you have files with lots of indents, you may want to optimize their size by enabling the Use tab character option in the Java code style settings.

For more details, refer to Reformatting Source Code.

Version control basics

To check out a project from a Version Control System (VCS), click Checkout from Version Control on the Welcome Screen, or in the main VCS menu.

To quickly perform a VCS operation on the current file, directory, or an entire project, use the VCS operations popup by pressing Alt+`

VCS Operations popup

Once you've configured the VCS settings, you'll see the Version Control tool window Alt+9.

The Local Changes tab of the Version Control tool window Alt+9 shows your local changes: both staged and unstaged.

Useful VCS shortcuts:

Action

Shortcut

Version Control tool window

Alt+9

VCS operations popup

Alt+`

Commit changes

Ctrl+K

Update project

Ctrl+T

Push commits

Ctrl+Shift+K

For more details, refer to Version Control with IntelliJ IDEA.

Branches

To perform an operation on a branch, either select Branches from the VCS main or context menu, the VCS operations popup, or the widget on the right of the status bar.

Note that for multiple repositories, IntelliJ IDEA performs all VCS operations on all branches simultaneously, so you don't need to switch between them manually.

Shelves, stashes and patches help you when you need to store some of the local changes without committing them to the repository. You can then switch to the repository versions of the files, and then come back to your changes later.

For more details, refer to Manage branches.

Make

By default, IntelliJ IDEA doesn't automatically compile projects on saving. To compile a project, select Build | Make Project from the main menu, or press Ctrl+F9.

For more details, refer to Compiling Applications.

Running and debugging

Once you've created a Run/Debug configuration by selecting Run | Edit Configurations from the main menu, you are able to run and debug your code.

Action

Shortcut

Run

Shift+F10

Debug

Shift+F9

When in the debug mode, you can evaluate any expression by using the Evaluate expression tool, which is accessed by pressing Alt+F8. This tool provides code completion in the same way as in the editor, so it's easy to enter any expression.

Sometimes, you may want to step into a particular method, but not the first one which will be invoked. In this case, use Smart step into by pressing Shift+F7 to choose a particular method.

Action

Shortcut

Toggle breakpoint

Ctrl+F8

Step into

F7

Smart step into

Shift+F7

Step over

F8

Step out

Shift+F8

Resume

F9

Evaluate expression

Alt+F8

If you want to "rewind" while debugging, you can do it via the Drop Frame action. This is particularly helpful if you mistakenly stepped too far. This will not revert the global state of your application, but will at least let you revert to a previous stack frame.

For more details, refer to Running and Debugging.

Reloading changes and hot swapping

Sometimes, you need to insert minor changes into your code without shutting down the process. Since the Java VM has a HotSwap feature, IntelliJ IDEA handles these cases automatically when you call Make.

Application servers

To deploy your application to a server:

  1. Configure your artifacts by selecting File | Project Structure | Artifacts (done automatically for Maven and Gradle projects).

  2. Configure an application server by clicking the Application Servers page of the Settings/Preferences dialog.

  3. Configure a run configuration by selecting Run | Edit Configurations, then specify the artifacts to deploy and the server to deploy them to.

You can always tell IntelliJ IDEA to build/rebuild your artifacts (once they have been configured) by selecting Build | Build Artifacts.

For more details, refer to Working with Application Servers.

Working with build tools (Maven/Gradle)

Once you've imported/created your Maven/Gradle project, you are free to edit its pom.xml or build.gradle files directly in the editor. Any changes to the underlying build configuration will eventually need to be synced with the project model in IntelliJ IDEA.

If you want the IDE to synchronize your changes immediately, do the following:

  • For pom.xml enable the Import Maven projects automatically option in File | Settings | Build, Execution, Deployment | Build Tools | Maven | Importing (Windows and Linux) or IntelliJ IDEA | Preferences | Build, Execution, Deployment | Build Tools | Maven | Importing (macOS).

  • For build.gradle, enable the Use auto-import option in Build, Execution, Deployment | Build Tools | Gradle of the Settings/Preferences dialog.

For manual synchronization, use the corresponding action on the Maven/Gradle tool window toolbar: the Refresh button.

Note that any goal or task can be attached to be run before a run configuration.

For more details, refer to Gradle.

Migrating from Eclipse or NetBeans

If you are considering the possibility to migrate from Eclipse or NetBeans to IntelliJ IDEA, refer to the migration guide for Eclipse or NetBeans.

What's next

You can watch a quick video of IntelliJ IDEA's overview to see what IntelliJ IDEA offers in code completion, inspections, formatting, and so on.

For more detailed information, we strongly advise you to read the documentation. Also you might find it useful to refer to the Java tutorials under Java SE, and also to the tutorial on Java EE.

Last modified: 26 April 2020