Chapter 1 - Basics
In this section, we will cover the basics of IntelliJ IDEA hotkeys, including general purpose commands such as copying and pasting, as well as using built-in IDE helper functionalities. By mastering these fundamental shortcuts, you will be able to perform common tasks more efficiently, allowing you to focus on your work and become more productive.
We recommend that you follow along with each exercise in this section to reinforce your understanding of the hotkeys and improve your muscle memory. Whether you are a seasoned developer or just starting with IntelliJ IDEA, this tutorial series will help you become more proficient and productive. So let’s get to it!
ctrl+c, ctrl+v
To copy text, select the text you want to copy using your mouse or keyboard, then press
ctrl + C. To paste the copied text,
move your cursor to the desired location and press
ctrl + V.
In this exercise, we will create a new constructor for Chapter1 without the number parameter, and initialize the number field to the default value
of 0. Copy the existing Chapter1 constructor by selecting the text using your mouse, then press
ctrl + C. Move your cursor to
a new line below the constructor, then press
ctrl + V to paste the copied text. Remove the number parameter from the newly
created constructor, and initialize the number field to 0.
Keep your hands on your keyboard
Do the same exercise, but ONLY use your keyboard to select text.
How to look up any actions’ shortcut 
ctrl+shift+a, double shift
Repeat the previous exercise, but instead of using
ctrl + C /
ctrl + V, use
ctrl +
shift + a to open the “Find Action” dialog. Type in the name of the action you want to perform, and IntelliJ IDEA will show you the
shortcut associated with that action. Alternatively, you can double-tab the shift key to open the quick action menu and search for the
action you want to perform. Use this method to look up the copy and paste actions, so you get a feel for using the dialog.
IntelliJ’s Productivity Guide
Open IntelliJ’s Productivity Guide using these key combinations:
First press
alt + h for (H)elp (in the taskbar), then press P to select (P)roductivity Guide.
bonus: Try opening the Productivity Guide using
Ctrl + Shift + A, then type in “Productivity Guide” in the
search bar.
Indenting, formatting with
tab, shift+tab
Open Fugly.java, use selection and indent the test builder patterns properly.
For this exercise, you can use shift and your arrow keys to select lines.
Use Tab to indent them manually, or use
ctrl + alt + l to automatically format the selected lines.
Hint: When manually indenting, first use
shift + Tab to unindent everything until the entire selection is against the left
side, then Tab the entire selection into its first indentation, decrease your selection and Tab that into its second
indentation. Rinse and repeat.
Auto-indent with
ctrl+alt+l
You can use this combination on specific lines, as well on entire files.
Open FuglyToo.java, select a couple of lines starting with the .withFace(face() line and press
ctrl + alt + l.
Now empty your selection (select nothing), and press
ctrl + alt + l again.
Undo, Redo
ctrl+z and
ctrl+shift+z
In most editors, Redo is mapped to
ctrl + y. Not so in IntelliJ.
This can lead to hilarious (or super annoying) situations where you’ll lose your undo buffer.
Let’s try it out and see what happens so you’ll remember it better.
Open FuglyToo.java once more.
Add a comment above the method that reads // this method is fugly.
Add a comment on a new line that reads // such fugliness should never be allowed.
Press
ctrl + z (Undo) and see what happens.
Press it a couple of times.
Now press
ctrl + shift + z (Redo) and see what happens.
Add these three comments to the file, each starting on a different line:
// herpty
// derpty
// derp
After you’ve typed the last line, press
ctrl + z until you only have // herpty left.
As most people will have the reflex to press
ctrl + y to Redo their work, let’s see what happens when we do just that.
Use
ctrl + y, then try
ctrl + shift + z to attempt and redo the revert you wish to reapply.
Try
ctrl + z and see what that does. Try
ctrl + shift + z again now.
`
Keep this strange behavior in mind when you work in IntelliJ, or in another editor that doesn’t have
ctrl + y for Redo :)