Top Shortcuts

Our handpicked top shortcuts just for you.

Context Actions

There are numerous ways to use Context Actions, let's explore some of them.

Also known as Fix anything, ⌥⏎ (macOS) / Alt+Enter (Windows/Linux) is a great shortcut to know by heart. Invoke Context Actions ⌥⏎ (macOS) / Alt+Enter (Windows/Linux) on any piece of code to see suggestions to improve or change your code.

IntelliJ IDEA offers intelligent suggestions most places in the code. It can offer fixes for compiler errors and inspection warnings. It can even use intentions to suggest other ways in which you could write code even if there's no warning or error.

IntelliJ IDEA lets you know that it has suggestions for you with a light-bulb on the left-hand side of the code. This light-bulb is red for errors, and yellow for other suggestions.

Alt Enter on errors

If there's an error in the code, pressing ⌥⏎ (macOS) / Alt+Enter (Windows/Linux), can suggest options that will make the code compile.

If there's a warning, IntelliJ IDEA will show you what the warning is, and may offer one or more suggestions on how to fix that warning. These warnings are often from inspections running on the code.

Even if the code is working perfectly well, pressing ⌘⌥⏎ (macOS) / Ctrl+Alt+Enter (Windows/Linux), will often show suggestions on other ways to express this code. These suggestions can help us to reshape the code, for example to make it more readable, or as part of a larger refactoring towards some other pattern. These suggestions can often be configured via intentions.

Alt Enter on errors

Use F2 (macOS) / F2 (Windows/Linux) to navigate to the next suggestion, or ⇧F2 (macOS) / Shift+F2 (Windows/Linux) to navigate to the previous suggestion in the file.