Useful Keyboard Shortcuts And Tips For IntelliJ IDEA
It goes without saying that IntelliJ IDEA is an extremely powerful IDE.
We’ve compiled a list of various tips and tricks to help you get the most out of this behemoth.
As is usually the case, the very best source of information regarding this piece of software is of course the official documentation. Everything is covered here. As you’ll no doubt notice, however, there is also a lot of information to sift through and unpack!
In this article, we won’t be covering all aspects of the IDE in an exhaustive manner for this very reason – but instead, presenting what we feel are some of the more useful suggestions and tips, touching upon a variety of different aspects of the system.
And with that said, let’s begin!
Utilise keyboard shortcuts to increase your productivity
First and foremost, let’s begin by looking at the various shortcuts and keybindings you can employ when developing software within IntelliJ IDEA.
Familiarising yourself with keyboard shortcuts is one of the best ways to improve your overall speed and efficiency in any program. IntelliJ IDEA is no exception to this rule.
For those of us who aren’t well acquainted with the use of keybindings in general, at first it may feel extremely clunky or odd to work in this way.
Over time, however, you’ll notice that it becomes a lot more comfortable – and as a result, your speed and efficiency will (or should) increase somewhat drastically.
If you scanned through the IntelliJ IDEA documentation referenced above, you’ll notice that there are basically keyboard shortcuts for everything. You can do more or less anything you require using the keyboard alone, without the requirement to touch the mouse at all.
Of course, we won’t be covering all of IntelliJ IDEA’s keybindings and their associated functionalities in this article — but let’s look at some of the more commonly used (and useful!) ones, in no particular order:
1. Go to line (Command+L, Control+G)
It’s often useful to be able to jump to a specific line within a file. When a work colleague tells you to “just check it out, it’s on line 4815” – nobody wants to scroll around their editor tab looking for this snippet!
Instead, use this keyboard shortcut to save yourself some time, and hop right to the required line.
It’s also handy to be able to snap back up (or down) to a particular line when you are darting around the same class or file whilst trying to debug an issue or something similar.
Likewise, exceptions usually reference the offending line number. You’ll want a quick way to get to this line without the requirement to scroll the mousewheel.
2. Go to declaration (Command+B, Ctrl+B)
This shortcut will take you to the declaration of your target symbol.
It’ll open the relevant file within the editor and position your cursor at this declaration for you. This is an extremely useful shortcut that allows you to quickly and easily step through your codebase at will.
That’s simply much quicker than either navigating to the file via the project tree on the left, or even searching by file name. It’s just the one click.
3. Search everywhere (Double shift)
You can search through the entirety of the project with this shortcut.
You can optionally filter by classes, files, symbols, actions and git via the provided interface.
4. Search within the file (Command+F, Ctrl+F)
A classic that nobody should be able to live without. You can also search within the given file specifically.
You’ll notice in the interface/toolbar that pops up that you can also search via RegEx (or a regular expression), you can filter your search (so for instance restrict the search to comments only) and so on.
There’s quite a bit of functionality here aside from the regular requirement to simply search the file for a particular string.
5. Search across files within the whole project (Command+Shift+F, Ctrl+Shift+F)
This is similar to the previous shortcut (search in file) but it allows you to search through all files within the project instead.
The same filtering tools are of course available to you, as well as the facility to search only through files of a specific type (using the file mask checkbox towards the top right of the panel) and the ability to search at numerous different levels (project, module or directory context for example).
6. Show recent files (Command+E, Ctrl+E)
This one’s really useful. It’ll display a list of recent files you’ve opened, you can optionally restrict this list to edited files only.
It’s particularly useful if you’ve forgotten the name of a file that you were checking out 20 minutes ago, for instance, and want to jump back in to this file to take another look.
It’s a handy piece of quality-of-life functionality that can help to ease your cognitive load in this way (the IDE will remember what you were doing 20 minutes ago, even if you can’t!)
7. Show usages (Option+F7, Alt+F7)
This will display all usages of a given symbol.
So you’ll see a list of each and every location where the particular method or member is in use within your project.
Again, this functionality can be modified as per your requirement.
You can restrict your search to only include usages within a specific directory, for example. You can omit generated code results and so on.
The functionality is really powerful and highly configurable, as with most IntelliJ IDEA functionalities outlined in this list.
8. Go to the next occurrence (Command+G, F3)
This one can be useful when renaming a variable.
Of course, there are other ways to rename variables (find and replace being the obvious choice) but with this approach, you can double-check or verify the usages of each and every member before you actually rename or replace it.
It’s also handy when debugging, as you can effectively step through the code within the given class via variable usages to help see what’s going on in each case.
So this functionality effectively provides a means to navigate through a specific file, too.
9. Close the current editor tab (Command+W, Ctrl+F4)
Much like when using the browser, it’s really handy to just be able to quickly close the current tab.
Having extra tabs open after you’ve finished with them can quickly lead to a cluttered and visually distracting IDE. It’s much better to just snap them shut and keep the screen free!
10. Navigate between editor tabs (Command+[/Command+], Alt+Left/Alt+Right)
Similarly, it’s much quicker to be able to quickly slide left or right to the other editor tabs.
You’ll find it extremely cumbersome to do this via the mouse once you’re familiar with this particular set of keyboard shortcuts.
11. Optimize imports (Ctrl+Option+O, Ctrl+Alt+O)
You can easily tidy up the imports in your file with this shortcut. Not only does this remove unused imports (should there be any), but it’ll reorder the imports for you.
It’s simply an easy way to help keep your code tidy and organised.
There are many other shortcuts to help keep your code clean and tidy. We won’t cover these specifically in this article, but you can check these out over here.
We won’t cover any other IntelliJ IDEA keyboard shortcuts for now, but hopefully you’ve got the idea.
There are keybindings for everything! And adopting them into your workflow will really benefit you in the long run.
Your productivity and overall efficiency should increase significantly over time.
Not only that, you can take your new way of working and apply it to other programs!
The same kind of infrastructure with regards to keybindings exists in a lot of software, and it’s there to be taken advantage of.
How to change keyboard shortcuts in IntelliJ IDEA
In IntelliJ IDEA, it’s really easy to customise the default keybindings to fit your requirement.
This is especially useful when you’re used to shortcuts from another program, and want to mimic them (ie. use the same key) in this IDE in particular.
You’ll often find that muscle memory takes over, and you find yourself instinctively reaching for a specific key combination to do a specific thing.
You can go to
Preferences > Keymap to do begin customising your keybindings.
Simply search for the target action(s) and assign your own keyboards shortcuts at will.
Split up the editor tabs for more direct visibility
There are times when it can be extremely useful to split up your editor into separate windows.
One file in the left side, one file in the right side.
As developers, we have limited real estate across our screen(s) — this can sometimes prove to be a hindrance. An example of this would be when you’re debugging or updating code in a large class. You may be implementing code towards the top of the file, but find you’re constantly needing to refer back to code towards the bottom of the file.
Of course, it’s not efficient or optimal to keep scrolling up and down each time, and it can be hard to properly maintain focus whilst performing this arduous routine.
For this reason, it’s often handy to duplicate the editor tab and view the lower code in the right hand side, whilst you edit the upper code in the left hand side (for example). Effectively splitting the screen in to two or more editor windows.
This is only one use-case, there are of course other other reasons why you’d want to duplicate or split your screen. Having direct visibility over two (or more) separate files within the project at the same time clearly has its benefits in some scenarios when working with code.
Control+Click on the editor tab and then click split right (or split down) to split your editor in this manner.
Local history to the rescue
It’s inevitable that there will be occasions where you need to see the recent history of a given file (or set of files).
Imagine you’re working on a new feature, and you’ve changed your implementation at the last moment (but didn’t commit the previous implementation). So you’ve lost that previous code, but now you want it back!
Fortunately, in IntelliJ IDEA, your previous changes aren’t necessarily lost in this case — you can use the local history feature! It’s certainly handy to know about this feature, and have it in the back of your mind for when these kind of scenarios do eventually occur.
Being able to restore files via this tool can be a real life saver. You can view the local history for a file or set of files via the following:
File > Local history > Show history
IntelliJ IDEA has your back!
Integrate your other tools to get the most out of the IDE
1. The database tab
You can connect to your database and interface with it directly via IntelliJ IDEA.
This is extremely useful, as it means you don’t need to use a separate GUI (or the command line) to do this. Everything can take place directly within your integrated development environment.
So for common operations like viewing records, examining your database’s structure, or running queries – IntelliJ IDEA has you covered. Well, it has you more than covered. There’s a wealth of functionality associated with the database integration.
Simply click the Database option on the right hand side of the IDE (or
View > Tool windows > Database) and begin configuring from here.
Once you’ve added your database, you can open a new query console and begin executing queries.
This can be really helpful to have during the development process, for example, as you can quickly and easily interface with your local database from the same place you are adding your code (ie. The IDE) – this really helps maintain focus and improves overall efficiency.
2. The terminal tab
Likewise, there’s a terminal integrated into IntelliJ IDEA, too.
You can navigate to
View > Tool windows > Terminal to open the terminal. It’ll appear docked at the bottom of the screen.
Much like the database integration, this is a useful feature as it’ll save you having to use an external terminal window outside of the IDE. IntelliJ IDEA really can handle basically any aspect of your development workflow.
Use the version control tooling
Your version control workflow can also be handled via IntelliJ IDEA.
Again, much like with the various integrations referenced above, it just means you don’t need to use an external program to handle this. You’ll have the necessary functionalities and GUI assistance to handle your version control directly within IntelliJ IDEA.
On Windows, you can go
File > Settings > Version control. On Mac, it’s
IntelliJ IDEA > Preferences > Version control.
The entirety of the version control system can be configured via this tooling.
Explore the available plugins
Often times when using new software, you’ll think (or assume) that you already have everything you need. That’s not necessarily the case!
You may be missing out on powerful utilities that you are yet to discover.
There are many useful plugins you can freely install for IntelliJ IDEA. These can help to empower you and bolster your productivity and overall development experience within the IDE.
If you open the
Preferences > Plugins window, you’ll be able to look through the various offerings.
Of course, a lot of plugin requirements may be language-specific. For example you may want to add language support for GraphQL via the GraphQL plugin. Or you may benefit from using React Buddy if you do a lot of React development.
Aside from this, there are lots of “generic” plugins that can enhance your IDE’s abilities in general, cosmetically or otherwise.
Search for “Theme”, and you’ll see lots of shiny new themes that you can apply. Themes aren’t necessarily a game-changer in terms of productivity or efficiency, but it’s definitely a good idea to make your IDE your own and ensure it’s a comfortable working environment that you enjoy to spend time in!
We’ve barely scratched the surface with regards to what’s possible within IntelliJ IDEA.
However, hopefully you’ve found some of the tips and hints to be useful! As a general overview, the two key takeaways from the article would be:
- There are keyboard shortcuts for (almost) everything in IntelliJ IDEA! Using these keybindings will significantly increase your productivity in the long run.
- It’s possible to integrate many different aspects of your development environment, routine and workflow into this IDE.
Hopefully this article provides a good primer and a decent foundation on which to move forward with enhancing your knowledge and further increasing your productivity as a developer.