Foojay Today

Everyday Shortcuts in IntelliJ IDEA

September 06, 2021

Let's take a look at some of my favourite keyboard shortcuts in IntelliJ IDEA.

It's really helpful to use keyboard shortcuts because it speeds you up and keeps you in the flow of coding!

Intention Actions - ⌥⏎ / Alt+Enter

You can use this shortcut in a number of places, even when it's not an error or when IntelliJ IDEA has not given you any indication that you could use it. It's always worth trying it just to see what your options are.

Let's say you have declared three strings in one statement and you want to split them into separate declarations. You can place the caret anywhere on line 7 and use ⌥⏎ / Alt&Enter and then select Split into separate declarations:

Alt and Enter to split declaration

When you press / Enter, you have three separate declarations:

Separate declarations

You can use ⌥⏎ / Alt&Enter in a number of different scenarios. It's always worth trying it to see what IntelliJ IDEA suggests in that respect.

Search Everywhere - ⇧⇧ or Shift+Shift

You can tap Shift twice to display the Search Everywhere dialogue:

Search everywhere

In this dialog, you can search for pretty much anything right across your project. For example, you can search for ignore, and then you can tab through the various options that are available to you.

Search everywhere tab

The Git view is fairly new and really helpful for searching through your Git commits.

Statement Completion - ⇧⌘⏎ / Ctrl+Shift+Enter

Statement completion is a great habit to get into because it means that IntelliJ IDEA will do the best it can to keep your code compiling. That includes not only putting semicolons in places where semicolons should be, but also opening and closing your brackets and putting your caret in the right place.

For example, you can press ⇧⌘⏎ / Ctrl+Shift+Enter here to add the semi-colon. Yes, in this example it's more key presses, but it's about getting into the habit because it will remove the element of not enough coffee that we all suffer from periodically.

Statement Completion - add semi-colon

Let's look at another example, you can type private void newMethod( and IntelliJ IDEA will close the bracket for you immediately, but then you can use Statement Completion again with ⇧⌘⏎ / Ctrl+Shift+Enter and IntelliJ IDEA will open and close the curly brackets and put the caret exactly where you expect it to be:

Statement Completion - add brackets

Reformat Code - ⌥⌘L / Ctrl+Alt+L

If you have some code that is badly formatted such as this one, there is a really easy way to fix it up. You can use ⌥⌘L / Ctrl+Alt+L to get IntelliJ IDEA to reformat the class for you:

Reformat Code

IntelliJ IDEA will then reformat your code to adhere to your coding and your style guidelines, which is really nice, especially if you've just been hammering away at the code!


Here are the four shortcuts that you can try in IntelliJ IDEA:

  • Context Actions - ⌥⏎ or Alt+Enter
  • Search Everywhere - ⇧⇧ or Shift+Shift
  • Statement Completion - ⇧⌘⏎ / Ctrl+Shift+Enter
  • Reformat Code - ⌥⌘L / Ctrl+Alt+L

There's also a video available on the IntelliJ IDEA YouTube channel.


Related Articles

View All


  • Helen Scott

    Helen is a Java Developer Advocate at JetBrains. She has over 20 years’ experience in the software industry which has been gained in a variety of roles including developer, technical ... Learn more

Comments (0)

Your email address will not be published. Required fields are marked *

Highlight your code snippets using [code lang="language name"] shortcode. Just insert your code between opening and closing tag: [code lang="java"] code [/code]. Or specify another language.

Save my name, email, and website in this browser for the next time I comment.

Subscribe to foojay updates:
Copied to the clipboard