9 IntelliJ IDEA features that I think you should be aware of
Posted 28 May 2022 by Erik Lumme
Every IDE has features that to some are vital for everyday work, but that others are not aware of. Here I list some of my favorite IntelliJ features.
1. The search-actions popup
In order to use a feature, you must find the feature. Similar to the palette in Visual Studio Code, the actions popup lets you search for actions and settings.
Not sure how to comment out a line, view a list of your breakpoints, or change the line separator? Simply press
Ctrl/Cmd + Shift + A, or go to
Help > Find Action..., and type away. The popup will also show you the shortcut for that action, if set.
2. Scratch files
Sometimes you want to try out a piece of code without having to run your application. This can be done in a test case or in an external process, but another convenient solution is to use scratch files.
Scratch files allow you to write and run short snippets of code, not just in Java. When running them, you will have access to the same classpath as you do when running the application. This is convenient for testing out a dependency.
You can create and view scratch files by searching for scratch in the actions popup. The same scratch files will be available across all your projects.
3. Regular expressions in the file search
You can search for something across all files using Find in Files (
Ctrl/Cmd + Shift + F). Not only can you apply a file pattern or scope to the search, you can also further refine it by searching with regular expressions. Regular expressions are enabled through the
.* icon on the right.
4. Pinning search results
If you want to go through all results of a search, and you also want to perform other searches without losing the original result, you can pin your search result.
To do this, first click on
Open in Find Window if your result is not there already. Then right click the tab of your results, and click on
Pin Tab. Congratulations, you’re now free to do new searches, find implementations, find references, and more, without losing your original search result.
5. The profiler
If you need to know where in the code the CPU spends most of its time, or what is using all of your memory, you will have to do some profiling. While there are plenty of tools out there for this purpose, such as VisualVM or JProfiler, nothing beats the convenience of having the profiler integrated into your development environment.
The profiler is available through
View > Tool Windows > Profiler. There you can profile a running process using an async profiler or the Java Flight Recorder. You can also take thread and heap dumps.
The profiler is not available in the community edition of IntelliJ IDEA.
6. Conditional breakpoints
Plain breakpoints are all very well, but there are times when you only want a breakpoint to be triggered under certain conditions. For example, there might be some code that maps database entities to JSON, and the mapping is incorrect only for a certain class.
Instead of a standard breakpoint that would be hit for every item, you can right click a breakpoint and set a condition under which it will be triggered.
7. Logging breakpoints
Who hasn’t added a few
System.out.println statements to the code for debugging purposes? They have a couple of drawbacks, though. First, you have to remember to remove all of them afterwards. Second, you must recompile the application for them to take effect.
A better approach is to use logging breakpoints. Simply right-click a breakpoint, click on
More, and check
Evaluate and log. You might also want to uncheck the
Suspend checkbox, so that the breakpoint will not cause the application to stop.
8. Run to cursor
After hitting a breakpoint when debugging, it’s common to walk through the next steps of the code execution, to see what happens on each line. If there are many lines of code that you’re not interested in, or perhaps a long for-loop, walking through it all can waste a lot of time.
One option is to put a breakpoint on the next line that you’re interested in, and resume program execution. A more convenient way is to simply right click on that line, and choose
Run to Cursor. This resumes program execution until that line. You can also choose
Force Run to Cursor, to ignore any additional breakpoints along the way.
9. The Key Promoter X plugin to learn shortcuts
Using keyboard shortcuts for commonly used actions is vital to being productive in an IDE. Plugins such as Key Promoter X can be of assistance in this regard, by notifying you when you’ve clicked on something that there is a shortcut for. It will also tell you what the shortcut is, and how many times you’ve missed it.
What are your favorite IntelliJ features? Let me know on Twitter!