IntelliJ IDEA Tips & Tricks

Top Underrated Shortcuts in IntelliJ IDEA

Read this post in other languages:

Shortcuts are in IntelliJ IDEA’s DNA: every possible action is at your fingertips – even those you didn’t think you needed.

We share helpful shortcuts with you quite frequently, so by now, you may very well be a shortcut expert. But believe it or not – there are a few shortcuts that perhaps not even you are aware of!

This post covers some of the underrated keyboard combinations IntelliJ IDEA supports. Check them out and give them a try! If you use any other lesser-known shortcuts, share them in the comments below.

Underrated Shortcuts

⌥ “x” or Alt+“x” – Close all inactive tabs

If your editor looks overloaded with open tabs, you can take care of this with just one key and a click. All you have to do is press (macOS) or Alt (Windows/Linux) and click the “x” on the active tab. The IDE will then close all inactive tabs at once, and the tab you are currently working on will stay open.

⇧⌘V or Shift+Ctrl+V – Choose content to paste

IntelliJ IDEA allows you to keep several recently copied items in the clipboard and paste any of them with the help of ⇧⌘V (macOS) or Shift+Ctrl+V (Windows/Linux). This means you don’t have to worry about losing any pieces of code you’ve copied recently.

⌥/ or Alt+/ – Use hippie completion

You are probably used to IntelliJ IDEA’s code completion mechanism, which offers suitable suggestions depending on the context. However, there may be cases when you simply want to reuse words that have been used earlier in the current file or even the project, regardless of their context.

Hippie completion works in such situations. You can use this feature by putting the caret at the desired position and pressing ⌥/ (macOS) or Alt+/ (Windows/Linux).

⌥⌘L or Ctrl+Alt+L – Reformat code

When working in a team, you usually share a unified code format. So, if the formatting in a project doesn’t correspond to the conventions you are using, select a piece of code you want to reformat according to your settings and press ⌥⌘L (macOS) or Ctrl+Alt+L (Windows/Linux).

⌘F12 or Ctrl+F12 – Navigate along file structure

This shortcut is for you if you are searching for an alternative way to quickly access methods used in your file. Instead of text search, you can open your file structure by pressing ⌘F12 (macOS) or Ctrl+F12 (Windows/Linux). Then, in the structure window that pops up, start typing the method name, navigate to the correct variant with the up and down arrows, and press Enter. That’s it!

⌃G or Alt+J – Select multiple occurrences

If you need to select and edit identical pieces of code quickly, then this shortcut is your best option. To use it, put the caret on the necessary symbol and press ⌃G (macOS) or Alt+J (Windows/Linux). Then, once the code element is highlighted, keep pressing this shortcut to move through the file. You will notice that the caret is being multiplied and appears next to every instance of the highlighted code element. If you start editing the highlighted code, this code will be changed automatically in every other instance.

⌘⇧↑/↓ or Alt +Shift+↑/↓ – Move lines

This shortcut is simple, yet very effective. Press ⌘⇧ (macOS) or Alt+Shift (Windows/Linux), and then use the up and down arrow keys to move the line where the caret is currently positioned into the desired position.

However, be careful when using this shortcut, as it can move lines out of scope.

If you are worried about moving lines outside of statements accidentally, use the shortcut that moves statements – ⇧⌘↑/↓ (macOS) or Ctrl+Shift+↑/↓ (Windows/Linux).

⌘D or Ctrl+D – Duplicate line

This shortcut is useful for when you need to add several similar lines but with different parameters. To try it out, place the caret at the line that needs duplicating and then press ⌘D (macOS) or Ctrl+D (Windows/Linux).

⌥ F3 or Ctrl+F11– Add mnemonic bookmarks

To quickly access folders, files, project items, and code lines, you can bookmark them with numbers (0 –9) or letters (A–Z). Once assigned, the IDE will show mnemonics in the gutter.

To add this kind of bookmark to a code line, place the caret on this line and press ⌥ F3 (MacOs) or Ctrl+F11 (Windows). To bookmark a file, package, folder, or module, select the necessary item in the Project list, and press the same shortcut.

Then, select the number or letter you want to use as an identifier for this bookmark in the popup. All done!

To jump to the bookmark, hold ^ (MacOs) or Ctrl (Windows) and then press the predefined digit or letter on your keyboard.

^` or Ctrl+` – Change view mode

IntelliJ IDEA offers a variety of view modes to meet your personal needs while coding. They include Presentation Mode, Distraction Free Mode, Full Screen, and Zen Mode. To activate them:

  • Press ^` (macOS), or Ctrl+` (Windows/Linux).
  • In the Switch dialog that appears, press 5.
  • Use the up/down arrow keys to select the desired mode or press the corresponding number.

To go back to the default view, repeat the same steps.

One of our favorites is Distraction Free Mode. It keeps you 100% focused on the task by hiding all UI elements and keeping the source code centered. Check it out!

⌘L or Ctrl+G – Go to line:column

This shortcut works perfectly when you know the exact place in the code where you need to navigate to quickly. Press ⌘L (macOS) or Ctrl+G (Windows/Linux) to open the Go to Line:Column dialog and enter the desired line or column number. You can also enter both, separating them with a colon (:). Click OK, and you are at the desired position.

⌘-/+ or Ctrl -/+ – Collapse and expand code blocks

Use this shortcut to see the file structure more clearly or quickly navigate to specific parts of a class. You can collapse all the expandable code blocks by pressing ⌘- (macOS) or Ctrl + – (Windows/Linux). To expand them back, press + in combination with or Ctrl.

⌘⇧A or Ctrl+Shift+A – Find action to add photo as background

This shortcut evokes various actions in the IDE that can be useful in many situations. However, today we want to share just one of these actions – one that you can use to give your IDE a cute and personalized touch.

Would you like to have a view of your favorite people, animals, things, or landscapes while coding? That’s easy – you just have to set a background photo.

To do so, press ⌘⇧A (macOS) or Ctrl+Shift+A (Windows and Linux) to conjure the Find Actions dialog and then type “background image”. Then, in the dialog that appears, select the path to the photo and configure other available settings however you like. For example, you can change the opacity of your image.

To return to your standard editor background, click the Clear and Close button in the previous dialog.

Bottom line

We hope you enjoyed our selection and found some unexpectedly helpful shortcuts you hadn’t heard of before. If you use other shortcuts that, in your opinion, don’t get the recognition they deserve, write about them in the comments. Let’s become keyboard masters together!

image description