Are you looking for ways to be more productive? It shouldn’t be a secret that performing actions using the keyboard instead of the mouse will save you time. If you think only about a single action it’s not a big deal. What if you use the same action multiple times a day? If you add up all these actions, they can have a great impact on your productivity.

Starcraft APM

I’m more or less used to drive most of my actions with keyboard shortcuts. When I was younger, I played Real Time Strategy computer games semi-professionally, including Starcraft and Warcraft III. Starcraft popularised the term APM (Actions per Minute), which counted the number of actions that a player performed per minute. By using tools, it was possible to record APMs and tell if players were using mouse actions or a keyboard and mouse action combination. Usually, players with a keyboard and mouse combination gameplay had a better chance of winning games than the one that just clicked.

So, what does this have to do with code and IntelliJ? Well, I believe that you can increase your code development productivity by learning and using the keyboard shortcuts to perform the desired actions. You can check the keyboard shortcuts on IntelliJ and you can also check the Productivity Guide which monitors your most used actions. This information is very useful, but it may be a little difficult to change your habits right away. To help you with this, I will describe my most used shortcuts in IntelliJ. You can start familiarize yourself with these and slowly introduce additional shortcuts.

Shortcut Description
CTRL + W / CMD + W Syntax Aware Selection: This allows you to select code with context. Awesome when you need to select large blocks or just specific parts of a piece of code. If you have this code:files.getFiles().forEach(auctionFile -> createAuctionFile(realm, auctionFile));And place the cursor in the auctionFile and use the shortcut, it will select auctionFile. Press it again and the selection will expand to auctionFile -> createAuctionFile(realm, auctionFile). If you press it again, now the selection will expand to files.getFiles().forEach(auctionFile -> createAuctionFile(realm, auctionFile)). Pressing a final time, you get the full piece of code selected.If you combine it with SHIFT, you can unselect by context as well.
CTRL + E / CMD + E Recent Viewed Files: This will show you a pop-up with all the recent files that you have opened in the IDE. If you start typing, you can filter the files.IDEA Recent Files
CTRL + SHIFT + E /CMD + SHIFT + E Recent Edited Files: Same as Recent Viewed Files, but only shows you the files that you’ve actually changed.
CTRL + B / CMD + B Go to DeclarationIf you place the cursor in a class, method or variable and use the shortcut you will immediately jump to the declaration of the element.
CTRL + SHIFT + ENTER/ CMD + SHIFT + ENTER Complete StatementThis will try to complete your current statement. How? By adding curly braces, or semicolon and line change. For instance, if you have the following statement:System.out.print()
Press the shortcut once to add an ending semi-colon. Press it again to add a new line and to position the cursor aligned with the last line.Another example:
if (condition == true)
Press the shortcut to add opening and closing curly braces, and place the cursor inside the if body with additional indentation.
CTRL + N / CMD + N Go to ClassThis one allows you to search by name for a Java file in your project. If you combine it with SHIFT, it searches any file. Adding ALT on top of that it searches for symbols. In the search area, you can use CamelHumps (type the capital letters only of the class name) notation to filter files.IDEA Go to Class
CTRL + SHIFT + SPACE/ CMD + SHIFT + SPACE Smart Type CompletionI didn’t mention it before, but I guess you are familiar with auto complete via CTRL + SPACE or CMD + SPACE. If you add a SHIFT you get the smart completion. This means that the IDE will try to match expected types that suit the current context and filter all the other options.
CTRL + ALT + ← /CMD + ALT + ← Navigate Back: This allows you to navigate back like a browser action. It remembers where your cursor was positioned and navigates back even to other files.
CTRL + ALT + → /CMD + ALT + → Navigate Forward: It’s like Navigate Back but goes Forward. Duh!
CTRL + SHIFT + F7 /CMD + SHIFT + F7 Highlight UsagesPlace the cursor in an element and after pressing the cursor the IDE will highlight all the occurrences of the selected element.

There are many more keyboard shortcuts. Almost every action has an equivalent shortcut. It’s hard to learn them all, it takes time and practice. I still learn new things every week, and if for some reason I don’t code as much for a few days, I forget about the new shortcuts I’ve learned. It’s practice, practice, practice! Try to learn a few and master them instead of trying to do everything in one go. It’s easier!

An IntelliJ plugin exists to tell you with shortcuts you should use if you use the mouse. It’s Key Promoter, but unfortunately it seems it’s not maintained anymore. Maybe I can update it for the latests IntelliJ versions. I would also like to see in the Productivity Guide a count of actions performed by shortcuts or mouse. If I find some free time, maybe I can do it too.

Hope you enjoyed it.

 

My Most Useful IntelliJ IDEA Keyboard Shortcuts

About The Author
- Freelancer. Passionate Java Developer.

2 Comments

  • gregor_riegler
    Reply

    A good starting point for beginners would be learning the refactoring shortcuts, and learning to automatically create code (functions, classes, parameters, constructors, gettets&setters) and so on.

  • Olivier Jacquemart
    Reply

    Great article 🙂

    I would add Ctrl + Shit + T to see the tests related to a class and then Ctrl + Shift + F10 to run the selected tests. Also, Ctrl + Q, to read the javadoc, is really useful, with Ctrl + Shift + I to see definition of a class or a method.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>