For whatever reason, my brain is averse to keyboard shortcuts. I cannot seem to master anything beyond the basics of Cut, Copy, Paste, and Select All. That being said, I am hopelessly inept to begin conquering vi and vim.
Yet, despite this mental blockade, I know that there are a few shortcuts that I would be shooting myself in the foot if I didn't take the time to learn. So after much trial-and-error, here are the eight shortcuts I would recommend anyone using JetBrain's suite of IDEs take time to learn.
Bear in mind that these shortcuts use these keymappings:
- Windows uses the Windows mapping
- Mac uses the IntelliJ IDEA Classic mapping
If you prefer another keymapping, I've named each of these shortcuts the same as IntelliJ so that you can look up the proper shortcut for your binding.
Duplicate Line or Selection: Ctrl + D, ⌘D
Eliminate copying and pasting lines of code to make only minor changes. This command will duplicate the existing line or the highlighted selection.
Extend Selection: Ctrl + W, ⌘W
This operation is perfect for whenever you don't want to use your mouse to highlight a code block. Pressing this key combination will start selecting the current word at your cursor. Pressing it again will expand that selection to include the current language token, the current line, the current block, function, class, etc... Each operation selects a wider range of your code.
The inverse of this action is Ctrl + Shift + W or ⌘⇧W.
Move Statement: Ctrl + Shift + Up/Down, ⌘⇧Up/Down
Need to move one line or code block up or down. This command is smart enough to apply that move operation to the relevant code (a line, if that is selected, or function or code block, if applicable) and format the code as it is moved around to keep the presentation clean.
Move Line: Alt + Shift + Up/Down, ⌥⇧Up/Down
Similar to the above command, except it makes a verbatim move without attention to context. This is nice if you really want to move just one line around, such as the beginning of an opening code block, without moving the entire code block with it.
You can also move a selection of code by highlighting it first.
Toggle All Tool Windows: Ctrl + Shift + F12, ⌘⇧F12
Whenever too many side panels get in the way, and you need to focus on your code, this key command will hide all open panels to show just your code. Calling this command again will restore your panels if you are already viewing just your code.
Back/Forward: Ctrl + Alt + Left/Right, ⌘⌥Left/Right
This is particularly helpful if you are making various edits on a large code file. You can work in one place, then navigate back to have your cursor jump to your previous section of code you had been editing. You no longer need to remember where you changed your code to pick back up from a previous thought.
This action also works across tabs.
Create/Go to Test: Ctrl + Shift + T, ⌘⇧T
Jumping between the unit test and implementation is quite simple. If you don't have a unit test for your code just yet, this shortcut will help you set up a stub file to get you going.
Select File in the Project View: Alt + F1, 1; ⌥F1, 1
Jumping straight to the open code file in the project view has many benefits and is something I use on a near-daily basis. Now, you can do it even faster with this key combination.
If I were going on a trip and could only take a handful of shortcuts with me, these would certainly make the cut. Hopefully, you will find them as helpful as I do. What is included in your daily mix of shortcuts? Please feel free to comment below.
If you enjoyed this article, please follow me on Twitter for all of my latest updates.