27 Essential IntelliJ Shortcuts to Boost Your Productivity

Spread the love

Using keyboard shortcuts in Intellij IDEA can save you a lot of time, increase your productivity and help keep your wrists healthy.

The most annoying thing you can use while coding is – MOUSE.

It just reduces your productivity while switching between the Keyboard and mouse. Use mouse as minimum as possible and learn these Keyboard shortcuts to improve your productivity. Grab your favorite caffeinated beverage and enjoy it.

I am not saying that you need to mesmerize 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.

Navigating

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. 

Searching

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.

Editing

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.

18. Reformat Code – Ctrl + Alt + L

Formating the code makes it more readable for all the developers. Just write your code and use the short cut to format it.

19. Auto Indent Line(s) – Ctrl + Alt + I

Indentation based on different loops and conditions will make code more flexible to understand. No need to manually indent it

Refactoring

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.

20. Extract method – Ctrl + Alt + M

To extract code to a new method or lambda expression simply select it and press Ctrl + Alt + M.

21. 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 the text. Pressing Shift + F6 once will rename the selected element across your entire codebase.

22. Change Signature – Ctrl + F6

Changing the signature of the method is the hassle-free process in IntelliJ Idea. Press the Short cut key and you can modify Parameters, Exceptions and Return types of the method and it will get refactored in the project.

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.

23. Step Into – F7

24. Step Over – F8

25. Evaluate Expression – Alt+ F8

26. Make project – Ctrl + F9

27. Run / debug – Shift + F10 / F9

You can also watch more Essential Tips and Tricks for IntelliJ IDEA here.

Now, As you have gone through all of it, You can finally say