Alt+Enter shows the action menu for the code under your cursor. In IntelliJ IDEA and Android Studio, it is the main shortcut for quick fixes, intention actions, inspections, imports, refactors, and small code transformations. On macOS, the usual equivalent is Option+Enter.
TLDR: Press Alt+Enter when the editor shows a red error, yellow warning, gray hint, or light bulb icon. In IntelliJ IDEA, it may import a class, create a missing method, simplify code, or apply an inspection fix. In Android Studio, it does the same, but also adds Android specific fixes such as resource corrections, Gradle suggestions, Compose imports, and manifest related actions. For example, if 30 imports are missing after pasting code, Alt+Enter can resolve many of them in seconds instead of forcing 60 to 90 manual clicks through menus and files.
What Alt+Enter Actually Does
Alt+Enter opens the context actions menu. That menu changes based on where your cursor is placed. If the caret is on broken code, you usually see a quick fix. If the code is valid but can be improved, you often see an intention action.
This is why the shortcut feels so useful. It does not perform one fixed command. It asks the IDE, “What can be done here?” Then it presents actions that match the code, project settings, language, framework, and installed plugins.
Common Alt+Enter actions include:
- Importing missing classes, functions, or static members.
- Creating missing symbols, such as methods, constructors, fields, or classes.
- Applying inspection fixes for warnings, errors, or style issues.
- Changing code structure, such as converting a lambda, inverting an
if, or replacing a loop. - Adding annotations, nullability markers, or suppression comments.
- Fixing project setup issues, especially in Android Studio.
Quick Fix vs Intention Action
The terms sound similar, but they are not the same.
A quick fix repairs a detected problem. The IDE has found something wrong or suspicious. You press Alt+Enter and get a choice that may fix it. Examples include importing List, creating a missing class, adding a required return statement, or changing a type mismatch.
An intention action changes valid code into another valid form. It is not always fixing a bug. It may improve readability, apply a coding style, or help with a refactor. Examples include converting a string concatenation to a template, replacing an anonymous class with a lambda, or splitting a declaration and assignment.
The catch is that both appear in the same Alt+Enter menu. That can confuse new users. A red error fix and a harmless style suggestion can sit in the same popup, even though their risk level is different. Read the action label before pressing Enter. One extra second here can save several minutes of undoing a bad change.
How IntelliJ IDEA Uses Alt+Enter
In IntelliJ IDEA, Alt+Enter is tied closely to the IntelliJ inspection engine. The IDE scans Java, Kotlin, Scala, Groovy, SQL, XML, build files, and many other file types depending on your edition and plugins.
Typical IntelliJ IDEA actions include:
- Import class or choose between multiple classes with the same name.
- Create method, field, parameter, class, interface, or enum.
- Cast expression or change variable type.
- Surround with try catch when a checked exception is not handled.
- Replace with newer language syntax, such as pattern matching or enhanced switch where supported.
- Suppress inspection for a statement, method, class, or file.
IntelliJ IDEA also uses Alt+Enter for serious code cleanup. For example, if an inspection detects redundant null checks or unreachable branches, the shortcut can remove them. If a variable can be declared final, it may suggest that too, depending on your inspection profile.
How Android Studio Uses Alt+Enter
Android Studio is built on the IntelliJ Platform, so the core behavior is very similar. Java and Kotlin fixes work much like they do in IntelliJ IDEA. The difference is the Android plugin. It adds actions that understand Android resources, XML layouts, Gradle files, manifests, Compose, and device related APIs.
Android Studio Alt+Enter actions often include:
- Import Android classes, including Compose functions and Material components.
- Create missing string resources from hardcoded text.
- Fix resource references in layouts, drawables, styles, and themes.
- Add missing permissions to the manifest when an API requires one.
- Update Gradle dependencies when a referenced library is missing.
- Convert layout attributes or suggest Android specific best practices.
It drives me crazy that Android Studio can take a few extra seconds to show the right action in large Gradle projects. Indexing, sync state, and plugin checks all affect it. If Alt+Enter shows weak or unrelated suggestions, wait for indexing and Gradle sync to finish before blaming the shortcut.
Key Differences Between IntelliJ IDEA and Android Studio
| Area | IntelliJ IDEA | Android Studio |
|---|---|---|
| Main focus | General JVM and multi language development | Android app development |
| Alt+Enter source | Core inspections and installed plugins | Core inspections plus Android plugin actions |
| Typical fixes | Imports, method creation, type fixes, refactors | Imports, resources, manifest, Gradle, Compose, XML |
| Project sensitivity | Usually tied to code model and language support | Also tied to Gradle sync, SDK setup, and Android plugin state |
The biggest practical difference is scope. IntelliJ IDEA is broader. Android Studio is more specialized. If you write backend Kotlin, IntelliJ IDEA may feel cleaner. If you write Android apps, Android Studio gives more relevant Alt+Enter fixes because it understands app resources and Android build rules.
When Alt+Enter Does Nothing
Sometimes Alt+Enter does not show anything useful. That usually means one of several things:
- The cursor is not placed on code with an available action.
- The file is not fully indexed yet.
- The project model is broken or not synced.
- The inspection that would detect the issue is disabled.
- The needed plugin is missing or disabled.
- The code is too broken for the IDE to infer a safe fix.
In Android Studio, check Gradle sync first. In IntelliJ IDEA, check indexing and inspection settings. In both tools, use Code > Show Context Actions from the menu if the keyboard shortcut has been remapped or captured by the operating system.
Best Practices for Using Alt+Enter
Alt+Enter is powerful, but it should not be used blindly. Some actions are mechanical and safe. Others change behavior.
- Use it immediately for imports. This is one of the safest and most common actions.
- Review generated code. A created method or constructor may have placeholder logic.
- Be careful with suppressions. Suppressing an inspection hides a warning; it does not solve the cause.
- Read alternate choices. If several imports share the same class name, pick the correct package.
- Use preview when available. Larger fixes may affect more code than expected.
Why Developers Rely on It
Alt+Enter cuts friction. It keeps your hands in the editor and reduces context switching. Instead of searching menus or typing boilerplate, you ask the IDE for the next valid move.
For a seasoned developer, this shortcut becomes a diagnostic tool. Red underline? Alt+Enter. Unused code warning? Alt+Enter. Missing Android resource? Alt+Enter. Strange Kotlin suggestion? Alt+Enter, then read carefully.
The serious value is not speed alone. It is consistency. IntelliJ IDEA and Android Studio apply the same inspection rules across a project, which helps teams keep code cleaner. Used well, Alt+Enter is less of a shortcut and more of a controlled gateway to the IDE’s code intelligence.