How to leverage IntelliJ to boost productivity when working with Java
One step closer to becoming an IntelliJ power user
- Firat Sivrikaya, Senior Software Engineer at EFG

IntelliJ IDEA is an inseparable part of our work, especially for those who need to maintain and develop Java services in our teams.
Most of us, however, do not utilize enough IntelliJ’s powers when working with Java. Utilizing the capabilities of IntelliJ helps improve the productivity of Java developers, code quality, and velocity.
In this article, I will be sharing a set of productivity tips that I find valuable and are available in IntelliJ Community Edition.
1. Shortcuts
Shortcuts are at the heart of IntelliJ and are one of the key points to boost your productivity and velocity. I won’t go into too much detail in shortcuts, but only list the ones that are IntelliJ-specific and that I find most useful in my daily routine.
Optimize imports: Control⌃ + Option⌥ + O
Removes unused imports and re-orders the imports. Can be also applied to multiple files when a folder or multiple files are selected in the project navigator.
Reformat code: Option⌥ + Command⌘+ L
Fixes the indentation, line breaks, and other styling issues. Can be also applied to multiple files when a folder or multiple files are selected in the project navigator.
Go back/forward in the code context
- Go back: Command⌘ + [
- Go forward: Command⌘ + ]
Very similar to how going back and forth works in web browsers, these shortcuts are crucial when trying to understand the code by going deep into the method usages and implementations between different layers of your codebase.
Complete Current Statement: Shift⇧ + Command⌘ + Enter⏎
This feature can address minor syntax issues and provide auto-completion in your code for atomic operations, such as adding a missing semicolon and creating curly braces and parentheses for loops conditional statements.
2. Code inspection for potential improvements
The code Inspection tool of IntelliJ is an amazing companion if you would like to detect problems in the codebase in the blink of an eye. Aside from proofreading your whole codebase, it can spot Java-related issues, categorize them according to their severity, and even propose solutions! This task is also useful for addressing the code quality concerns raised by Sonarqube.
To run the task, right-click on your project folder (or any sub-folder of your project), then choose Analyze > Inspect.
After a few seconds, the results will appear in the “Problems” tab. By expanding each problem category, it is possible to preview where the problem is located in the code and navigate there via the Command⌘ + Downwards Arrow↓ shortcut.
3. Extract method
When your method grows too big and code redundancy increases, it is time to extract methods from the code pieces to improve the readability and DRY the code. IntelliJ provides a great tool to extract codes to new methods, which is even capable of replacing all the usages if the code is repeated elsewhere in the same class!
To use it, highlight a portion of code that is extractable to a method, then press Option⌥ + Command⌘ + M. Give the extracted method a name, then press Enter to save the changes.
In the example below, the validation operations in a controller method are extracted to a private method.
4. Multiple cursors and selection ranges
When you want to apply a change to multiple places in a single file, multiple cursors come to your help. It saves so much time especially when there are redundant changes to be made. To enable multiple cursors, simply hold Option⌥ + drag the left mouse key to where you want to place the cursors.
Multiple cursors also support advanced features, such as Live Templates and Code Completion.
In the example below, a portion of JSON with invalid syntax is converted to a valid one using multiple cursors.
5. Generate
Creating a new class from scratch almost always involves boilerplate operations. IntelliJ can help developers simplify such operations with its productivity tool, Generate.
Generate is capable of creating a constructor, overriding parent methods, implementing interface methods and even generating a test class with all the testable methods in the correct package!
To display the Generate tool dialogue, simply press Control⌃ + Enter⏎ in a Java class, and choose the action you would like to execute.
In the example below, using the Generate tool, the methods coming from the interface are implemented, a constructor is generated and tests are created based on the chosen methods.
6. Context Actions
Also known as “Fix anything” in the IntelliJ community, the context actions feature is a must-know for everyone. When the shortcut is invoked on a piece of code, IntelliJ shows you its suggestions to improve your code or choose a different style of writing the same code.
To use Context actions, click on anywhere in your code where you want to get suggestions, then press Option⌥ + Enter⏎.
In the example below, Context actions are used to do static import, and apply different programming styles on the loop and streams. Pressing F1 previews the changes proposed next to the highlighted action.
7. Refactor This
Refactoring tasks are an essential part of the software development lifecycle, and they are usually dull, repetitive, and time-consuming. By using the “Refactor This” tool of IntelliJ, refactoring tasks become much simpler and take less time.
The tool offers the options to rename a method/field/variable, extract interface and superclass, migrate types, introduce constants, and many more.
To display the possible refactoring options, click on anywhere in the code to be refactored, and press Control⌃ + T.
In the example below, the “name” field in a DTO class is renamed to “username” by using the tool. The tool renames and replaces all the instances and usages of the field within the project, including the renaming of getter and setter methods.
Conclusion
These are only a subset of productivity tools offered by IntelliJ and the ones I find myself using daily. For the sake of readability, I only provided brief descriptions and visual examples, but there’s a lot more to read in the official documentation. For those who are interested, below is a list of follow-up reads and references to the documentation:
- Live templates | IntelliJ IDEA
- Code inspections | IntelliJ IDEA
- Generate code | IntelliJ IDEA
- Multiple cursors and selection ranges | IntelliJ IDEA
And here’s a bookmark proposal, if you would like to follow the tips & tricks periodically shared in the official blog of IntelliJ: