IntelliJ Keyboard Shortcuts - Compile, Debug, Run

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

Overview

In this tutorial, we will show some additional useful keyboard shortcuts which will help you be more productive when developing your Scala applications using IntelliJ.

 

Steps

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

 

intellij open scala project

 

2. Inspect expression type
The following keyboard shortcut will allow you to inspect the type for a given expression:

 

Keyboard Shortcut Windows Mac
Inspect expression type Alt + = Ctrl + Shift + P

As an example, say you wanted to know the type of the args variable which we inherited by extending the App trait in HelloWorldWithArgumentsDebug from Tutorial 07.

 

Sure, you could navigate to the definition of the args variable. But when you have multiple functions which are being chained, this constant switching back and forth between editor windows would become a distraction!

 

Instead, place your cursor on the args variable and press Alt + = if you are using Windows or Ctrl + Shift + P if you are on a Mac. You will then see a tooltip which will show you the type of the args variable. In our example, the type is an Array of String.

 

intellij keyboard shortcut refactor

 

NOTE:

  • As we've mentioned in the Scala Introduction tutorial, Scala is both an Object Oriented and Functional programming language. On the functional side which we will see in upcoming tutorials, chaining functions together may change the return type of your expression.
  • As a result, this keyboard shortcut is perhaps the one which you will find most useful when writing your Scala code!

3. Compile any modified files
The following keyboard shortcut will allow you to compile your Scala application:

 

Keyboard Shortcut Windows Mac
Compile any modified files Ctrl + F9 Cmd + F9

This is equivalent to selecting the Make Project from the Build menu:

 

intellij keyboard shortcut compile

 

NOTE:

  • IntelliJ keeps track of any modified files and the above keyboard shortcut will compile only those files that have been modified.
  • If you would like to compile specific module, package or project, you can select them from the Project panel on the left hand side and then select Build and then Compile.

intellij keyboard shortcut compile selected

 

You can also use the following keyboard shortcuts:

 

Keyboard Shortcut Windows Mac
Compile selected module or package Ctrl + Shift + F9 Cmd + Shift + F9

4. Run your Scala application
The following keyboard shortcut will allow you to quickly launch your Scala application in Run mode:

Keyboard Shortcut Windows Mac
Run Scala Application Shift + F10 Ctrl + R

NOTE:

  • This is equivalent to selecting the Run menu item from the Build menu.

intellij keyboard shortcut run

 

5. Debug your Scala application
The following keyboard shortcut will allow you to quickly launch your Scala application in Debug mode:

 

Keyboard Shortcut Windows Mac
Debug Scala Application Shift + F9 Ctrl + D

NOTE:

  • This is equivalent to selecting the Debug menu item from the Build menu.

intellij keyboard shortcut debug

 

6. Stepping through the debugger
The following keyboard shortcuts will help you navigate your way through debugging your Scala applications.

 

Keyboard Shortcut Windows Mac
Step over F8 F8
Step into F7 F7
Step out Shift + F8 Shift + F8
Resume F9 Cmd + Alt + R

This concludes our tutorial on IntelliJ Keyboard Shortcuts - Compile, Debug, Run 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:

  • How to inspect an expressions's type
  • How to compile only modified files
  • How to Run your Scala application
  • How to Debug your Scala application
  • How to step through your Scala application in debugging mode.

Tip

  • A full list of Windows and Mac keyboard shortcut from the JetBrains website.
  • Cheatsheet of the additional shortcuts we've used in this tutorial.
Keyboard Shortcut Windows Mac
Additional useful shortcuts    
Inspect expression type Alt + = Ctrl + Shift + P
Compile modified files Ctrl + F9 Cmd + F9
Run Scala application Shift + F10 Ctrl + R
Debug Shift + F9 Cmd + D
Debugging: Step over F8 F8
Debugging: Step into F7 F7
Debugging: Step out Shift + F8 Shift + F8
Debugging: Resume F9 Cmd + Alt + F

Source Code

The source code is available on the allaboutscala GitHub repository.

 

What's Next

If you have followed the previous tutorials, you should by now feel more comfortable with IntelliJ IDEA.

 

This would be a good place to proceed to Chapter 2 where I will provide the basic foundations of the Scala language.

 

Stay tuned!

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: