Using keyboard shortcuts in Intellij IDEA can save you a lot of time, increase your productivity and help keep your wrists healthy. We’ve collected the top 21 must-know shortcuts and keystroke combinations to take your Intellij mastery to the next level.
Being productive while coding is not just about avoiding social media and other annoying distractions. When you remove all the external noise, it’s just you, your IDE of choice, your keyboard, mouse, and a caffeinated beverage. One of these is usually unnecessary – the mouse.
Why Keyboard Shortcuts Are Awesome
It’s not that we have anything against pointing devices, but let’s face it – those are the tools of graphic designers. And even graphic designers use (usually one-handed) keyboard shortcuts in their work. When you’re in that lightning-speed code-typing mode, looking for menu items is nothing but a distraction, even when you know exactly what you are looking for.
For a developer to waste precious time moving their hand from the keyboard to the mouse and back is simply ineffective. All those little seconds really do add up in damaging the overall efficiency of your work. In addition, it can cause fatigue and pain in the wrist and arm from the frequent switching between input devices.
Top 21 Productivity-Boosting Intellij IDEA Shortcuts
Now that you’re fully convinced of the value of memorizing and using keyboard shortcuts instead of clicking on menus, we have some great news! Intellij IDEA can do pretty much all you need it to without you even touching the computer mouse of trackpad to execute a command.
That said, there’s really no reason for you to memorize the full Intellij IDEA default keymap sheet, though you might want to print the page applicable to your OS of choice and hang it somewhere you can easily see around your workstation.
So which of the 100+ shortcuts should you memorize? We picked the top 21 in boosting productivity, and sorted them into categories according to use. Note that we used the default OS and Intellij keymap, and the key combinations assume a Windows OS. If you use a Mac or run Linux, you can easily “convert” the shortcuts using the official Intellij IDEA keymap sheet.
One of the main challenges in “quitting the mouse” with Intellij IDEA is learning to navigate between files, tabs and sections of code using keyboard shortcuts. It’s actually more effective than using a mouse and guess what? No leaning on the up and down keys is involved!
1. Go to declaration / implementation – Ctrl + B / Ctrl + Alt + B
When you need to find the declaration of a method, all you need to do is select the method and press Ctrl+B on your keyboard. Need the implementation section instead? Press Ctrl + Alt + B to jump to the method implementation.
2. Navigate to last edit location – Ctrl + Shift + Backspace
“Wait, so where was I typing last?” will never be a question you ask yourself when going back to work after lunch. Simply press Ctrl + Shift + Backspace and you’ll be taken to the last edit location in the file.
3. Switch between tabs – Ctrl + Tab
Everyone knows how useful the Alt + Tab key combination is, especially when switching between, let’s say, Google (or your social media account) and the IDE. Now, you can also switch quickly and easily between open files in the same way with Ctrl + Tab.
4. View recent files – Ctrl + E
Want to open a recent file? Pressing Ctrl + E will let you navigate the list of recent files and pick the one you wish to open in a tab.
5. Go to line – Ctrl + G
When a coworker yells across the room “Check line 732!” you don’t need to go on a scrolling marathon. Simply press Ctrl + G and go directly to the line in question.
6. Navigate to test – Ctrl + Shift + T
Jumping between implementation and testing classes is a breeze with this handy key combination. Added bonus – if your implementation class doesn’t have a test class, Ctrl + Shift + T will automatically create one for you using your default testing framework.
Finding what you need in thousands of lines of code across multiple documents is no easy task when done manually and is a bit like finding a needle in a haystack of code. Fortunately, there are several search functions (with keyboard shortcuts) in Intellij IDEA to help you locate the code segments, classes, methods or other resources you’re looking for as quickly as possible.
7. Comprehensive search – Double Shift
Look for anything anywhere with this handy double-press. Using TAB switches the resulting cluster, left arrow key will show history, right arrow key will move forward, and the most recent files are shown by default.
8. Find class – Ctrl + N
Looking for something classy? To find the class you seek simply press Ctrl + N and type the name. You don’t even need to write the full name, and you can use asterisks (*) as wildcards.
9. Find resource – Ctrl + Shift + N
When you’re not looking for classes but rather for text or configuration files, Ctrl + Shift + N will do just in a fashion similar to that for finding classes.
10. Show usages – Ctrl + Alt + F7
Ever looked at a component in the code and ask yourself “Wait, what does this do?” before going on a long quest to answer that question? Never again! Ctrl + Alt + F7 shows all usages of the current method, class or variable in a popup where you can easily navigate between locations where it was used.
As a coder, what you usually do is write and edit code. Those important keystrokes of genius that make the words in the IDE turn into working applications. Some keystrokes are unnecessary and repetitive. These shortcuts will help eliminate those so every one of your keystrokes counts.
11. Expand / shrink selection – Ctrl + W / Ctrl + Shift + W
Selecting code sections with a mouse is a drag. Aside from being a pun, it’s also a great way to miss important bits which we would rather not miss. Instead, you can use Ctrl + W to expand the selection intelligently and Ctrl + Shift + W to shrink it.
12. Basic code completion – Ctrl + Space
“Type less, do more,” is the main idea behind this keyboard shortcut (and the two that follow it). This important shortcut will autocomplete your code, but much like the default autocomplete on your mobile, is not perfect. It is, however, very widely used.
13. Smart code completion – Ctrl + Shift + Space
Smart code completion is much more effective as it will only display the autocomplete options relevant to context by filtering the list of suggestions to show only classes, variables, fields and methods of the type that can be expected.
14. Complete statement – Ctrl + Shift + Enter
The bane of any and every developer from day one of the job are those missing characters in statements like parentheses and semicolons. This keyboard shortcut helps eliminate those and can be a lifesaver on long nights of coding.
15. Show intention actions and quick-fixes – Alt + Enter
Another helpful keyboard shortcut to improve your code is Alt + Enter that will automatically fix highlighted errors or warnings, then improve or optimize the selected code construct.
16. Duplicate line – Ctrl + D
Anyone who’s ever written code will tell you no key combination is more useful than good old Ctrl + C and Ctrl +V. In Intellij IDEA you can duplicate lines by pressing Ctrl + D. Note that you can also do this with whole sections of code.
17. Comment line – Ctrl + /
Deleting code is rare. More often than not, you will comment out lines of code for testing purposes or various reasons. Commenting out lines is made quick and easy by then pressing Ctrl + / no matter where you are in the line.
One of the main strengths of Intellij IDEA is its refactoring functions and opportunities. The most used ones have shortcuts you’ll probably memorize pretty quickly if you refactor your code a lot.
18. Extract method – Ctrl + Alt + M
To extract code to a new method or lambda expression simply select it and press Ctrl + Alt + M.
19. Rename – Shift + F6
Renaming in Intellij requires some setting up before using. If you don’t adjust renaming options (double-pressing Shift + F6), you might find that it will also rename occurrences in text. Pressing Shift + F6 once will rename the selected element across your entire codebase.
Compiling / Debugging
The last two keyboard shortcuts need no explanation as they map to two of the most commonly used functions of an IDE – making projects, debugging and running them.
20. Make project – Ctrl + F9
21. Run / debug – Shift + F10 / F9
Those are just our favorite shortcuts, and only 21 of them. Which are yours? Tell us in the comments.