IntelliJ Keyboard Shortcuts - Search Shortcuts

By Nadim Bahadoor | Last updated: July 25, 2017 at 13:31 pm

Overview

In this tutorial, we will show some of the most common IntelliJ search keyboard shortcuts which will help you be more productive when writing your Scala projects.

 

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 IDEA Open Project

 

2. Search everywhere
The keyboard shortcut below will open a dialog where you can simply type in any file you are looking for.

 

Keyboard Shortcut Windows Mac
Search everywhere Press shift key twice Press shift key twice

As an example, say you wanted to have a look at the implementation of the App trait which we saw in Tutorial 5. By pressing the shift key twice, you will see a search dialog where you can enter App and it will list the matching results. You can use the up and down arrows to select the file and press the enter key to open it.

 

intellij search press shift shift

 

3. Find references

The keyboard shortcut below will find any files which are referencing your given selection.

 

Keyboard Shortcut Windows Mac
Find references Alt + F7 Alt + F7

So far in our allaboutscala project, we've used the App trait in a few places. If you would like to find all the files that are extending the App trait, you can first open the App trait using for example Step 2 above. You then place the cursor on the App trait name and then press Alt + F7. You will see a list of Scala classes that are referencing the App trait in your project as follows.

 

ntellij search find references

 

NOTE:

  • From the search result, you can simply double click on any of the files to jump to the exact line number where the App trait is being referenced.
  • While we have not discussed Scala functions yet, you can use the same Alt + F7 shortcut to find say all Scala classes which are referencing a particular function.

4. Search in a file

The following keyboard shortcut will open a search panel in the file you are currently editing which will allow you to search within that particular file.

 

Keyboard Shortcut Windows Mac
Search in a file Ctrl + F Cmd + F

 

intellij search in a file

 

5. Fine grained search
The following keyboard shortcut will open a search dialog with fine grained options to allow you to optimize your search.

 

Keyboard Shortcut Windows Mac
Fine grained search Ctrl + Shift + F Cmd + Shift + F

 

In the search dialog, you have the usual textbox where you can enter the text you are looking for. However, there are other added options such as case sensitivity, regular expressions, the scope of the project and specific filters. These will in turn further restrict your search and can be especially handy in Scala projects with a large code base.

 

intellij search filters in a file

 

6. Quick search and replace
The following keyboard shortcut will allow you to use your cursor location to find and select any similar matching items.  In addition, all the selected items will become editable.

 

Keyboard Shortcut Windows Mac
Quick search and replace Alt + J Cmd + Ctrl + G

 

As an example, say you wanted to replace all the println function in HelloWorldWIthArgumentsDebug Scala file with Console.println. By place your cursor on the first println function and then pressing Cmd + Ctrl + G if you are on Mac or keep pressing Alt + J if you are using windows, IntelliJ will highlight and make all the println function calls editable.

 

intellij search replace

 

You can then simply replace all the println in one go by typing Console.println

 

intellij search refactor

 

This concludes our tutorial IntelliJ Keyboard Shortcuts - Search 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:

  • How to search for a particular file anywhere
  • How to search files which are referencing a particular class, trait, function etc
  • How to search in a particular file
  • How to search with more fine grained search criteria
  • How to quickly search and replace

Tip

  • A full list of Windows and Mac keyboard shortcut from the JetBrains website.
  • Cheatsheet of the search shortcuts we've used in this tutorial:
Keyboard Shortcut Windows Mac
Search    
Search everywhere Press the shift key twice Press the shift key twice
Search references Alt + F7 Alt + F7
Search in a file Ctrl + F Ctrl + F
Find grained search Ctrl + Shift + F Cmd + Shift + F
Quick search and replace Alt + J Cmd + Ctrl + G

Source Code

The source code is available on the allaboutscala GitHub repository.

 

What's Next

In the next tutorial, I will show some more useful keyboard shortcuts with regards to finding the return type of a function,  compiling, running and debugging shortcuts.

Nadim Bahadoor on FacebookNadim Bahadoor on GithubNadim Bahadoor on LinkedinNadim Bahadoor on Twitter
Nadim Bahadoor
Senior Software Developer | Elsevier
Founder of allaboutscala.com. I have over 10 years of experience in building large scale real-time trading systems in the financial industry. Passionate about Distributed Systems, Scala, Big Data and Functional Programming. Stay in touch for upcoming tutorials!
Other allaboutscala.com tutorials you may like:

Share this article on