IntelliJ Keyboard Shortcuts - Navigation Shortcuts

By Nadim Bahadoor | Last updated: March 16, 2018 at 11:12 am

Overview

In this tutorial, we will show some of the most common IntelliJ IDEA navigation keyboard shortcuts. You should take the time to get familiar with these shortcuts as they will help you be more productive when writing your Scala code in IntelliJ.

 

Steps

1. Open IntelliJ and our allaboutscala project
If you do not have IntelliJ installed or the allaboutscala project, please follow the previous tutorials.

 

IntelliJ Open Scala Project

 

2. Go to a particular class
The keyboard shortcut below will open a dialog where you can type in the Scala class you would like to open:

 

Keyboard Shortcut Windows Mac
Go to a particular class Ctrl + N Cmd + O

As an example, say you wanted to open the HelloWorldWithArguments Scala class which we created in Tutorial 6. By starting to type HelloWorld, you will see a list of Scala classes which starts with HelloWorld and you can then use the up and down arrow keys to navigate through the list. To open the selected file, simply hit the enter key.

 

intellij shortcut search class

 

3. Go to a particular resource file
The keyboard shortcut below will open a dialog where you can type in the resource file you would like to open:

 

Keyboard Shortcut Windows Mac
Go to particular resource file Ctrl + Shift + N Cmd + Shift + O

As an example, say you wanted to open the build.sbt file for our allaboutscala project. By starting to type build, you will see a list of files which start with build and you can then use the up and down arrow keys to navigate through the list. To open the selected file, simply hit the enter key.

 

intellij shortcut search file

 

4. Open type hierarchy
The keyboard shortcut below will open the Type Hierarchy panel for a particular Scala class:

 

Keyboard Shortcut Windows Mac
Open Type Hierarchy Ctrl + H Cmd + H

As an example, open HelloWorldWithScalaLogging from Tutorial 10 and place your cursor on the App trait. Then hit Ctrl + H and you will see the Type hierarchy panel open on the right hand side:

 

intellij shortcut open type hierarchy

 

5. Go to declaration
The following keyboard shortcut will navigate to the declaration of the selected function or type:

 

Keyboard Shortcut Windows Mac
Go to a declaration Ctrl + B Cmd + B

As an example, open HelloWorldWithScalaLogging from Tutorial 10 and place your cursor on the App trait:

 

intellij shortcut go to declaration

 

Then hit Cmd + B and IntelliJ will open the App trait declaration as follows:

 

scala app trait

 

6. Go back to last edit location

The following keyboard shortcut will navigate back to your last edit location:

 

Keyboard Shortcut Windows Mac
Go back to last edit location Ctrl + Shift + Backspace Cmd + Shift + Backspace

Say you've followed Step 5 above and opened the App trait declaration but now would like to go back to your last edit location. By simply pressing Cmd or Ctrl+ Shift + Backspace, IntelliJ will navigate back to the HelloWorldWithScalaLogging file which was your last edit location.

 

This can be very handy if you have many files open and are switching back and forth between function implementations.

 

7. Open the file structure
The following keyboard shortcut will open the file structure of a particular Scala class:

 

Keyboard Shortcut Windows Mac
Open the file structure Ctrl + F12 Cmd + F12

Say you've followed Step 5 and opened the App trait declaration but would like to see a quick overview of its functions and variables. By simply pressing Cmd + F12 if you are a Mac user, you will see the App trait's structure as follows:

 

intellij shortcut open file structure

 

NOTE:

  • With the file structure view, you are able to quickly see that the App trait has three functions namely args, delayedInit and main.
  • It also has three variables named executionStart, _args and initCode.
  • This view can also be useful if you would like to quickly jump to a particular function declaration.

8. Go to particular line number
The following keyboard shortcut will allow you to jump to a particular line number in a Scala file:

 

Keyboard Shortcut Windows Mac
Go to a particular line number Ctrl + G Cmd + L

Say you've followed Step 5 and opened the App trait declaration but would like to quickly jump to line number 64. By simply pressing Cmd + L if you are a Mac user, IntelliJ will move the cursor to line 64.

 

intellij shortcut go to line

 

NOTE:

  • This can be very handy if you are working in a team and someone asks you to review a particular line of code.
  • If you prefer to see all the line numbers for a particular file, you can right click on the left sliver of the file and select Show Line Numbers

intellij shortcut show line numbers

 

This concludes our tutorial on IntelliJ Keyboard Shortcuts - Navigation Shortcuts and I hope you've found it useful!

 

Stay in touch via Facebook and Twitter for upcoming tutorials.

 

Don't forget to like and share this page :)

Summary

In this article, we went over the following:

  • Keyboard shortcut for navigating to a class
  • Keyboard shortcut for navigating to a resource file
  • Keyboard shortcut for opening the type hierarchy panel
  • Keyboard shortcut for navigating to declaration
  • Keyboard shortcut for navigating back to the last edit location
  • Keyboard shortcut for opening the file structure panel
  • Keyboard shortcut for navigating to a particular line number

Tip

  • A full list of Windows and Mac keyboard shortcut from the JetBrains website.
  • Cheatsheet of the navigation shortcuts we've used in this tutorial:
Keyboard Shortcut Windows Mac
Navigation    
Go to a class Ctrl + N Cmd + O
Go a a resource file Ctrl + Shift + N Cmd + Shift + O
Open type hierarchy Ctrl + H Ctrl + H
Go to declaration Ctrl + B Cmd + B
Go back to last edit location Ctrl + Shift + Backspace Cmd + Shift + Backspace
Open file structure Ctrl + F12 Cmd + F12
Go to a particular line number Ctrl + G Cmd + L

Source Code

The source code is available on the allaboutscala GitHub repository.

 

What's Next

In the next tutorial, I will show some of the most commonly used keyboard shortcuts with regards to search within IntelliJ.

Nadim Bahadoor on FacebookNadim Bahadoor on GithubNadim Bahadoor on LinkedinNadim Bahadoor on Twitter
Nadim Bahadoor
Technology and Finance Consultant with over 14 years of hands-on experience building large scale systems in the Financial (Electronic Trading Platforms), Risk, Insurance and Life Science sectors. I am self-driven and passionate about Finance, Distributed Systems, Functional Programming, Big Data, Semantic Data (Graph) and Machine Learning.
Other allaboutscala.com tutorials you may like: