Developers waste a few seconds every time they take their hand off the keyboard and move it to the mouse to execute an action in their IDE. I have heard devs claim that learning shortcuts is a waste of time and effort when the same tasks can be accomplished with the mouse. In my experience it doesn’t take long to learn them if you use them regularly. They shave precious minutes off development time and allow you to focus on the code rather than look around in the menu options to try and locate the task you need to do.
Pro tip #1: The more you use shortcuts the easier it gets to remember lots of them.
Pro tip #2: If it gets difficult to remember the various key combinations try instead memorising the position of your fingers on the keyboard. I often can’t tell someone the key combination required for an action but give me a keyboard and my fingers go to the right keys by force of habit.
These are my top 7 shortcuts for PHPStorm. They should also work in IntelliJ and RubyMine.
⌘⇧a – Enter action or option name
The king of shortcuts, ruler of the kingdom. It pops up a prompt where you can type in almost any action that the IDE can perform. It provides auto-fill and also shows you the shortcut for your desired action so that you can memorise it for next time.
⌘⇧8 – Column selection mode
Allows you to select text vertically instead of horizontally. When you’re done reset to the usual selection mode by pressing the same shortcut again.
⌥↑ – Select word at caret
This one is the underdog, not used enough and underrated. Press it once to select the word at the caret and keep going to select the next logical block. Use the down arrow instead of up to go in reverse. This one is very useful when you have a lot of function calls and nested control statements and you want to select some portion for extracting out into a method or variable.
⌘⇧v – Paste from history
Every developer is familiar with ⌘c (copy) and ⌘v (paste) but this shortcut allows you to paste the last 5 copied items. This number can be customised in your IDE and I usually set it to 10. If you want to copy a number of different snippets from one file and paste them in another you can copy them all and then paste them one at a time using this shortcut.
⌘⇧↑ – Shift selection up
Select some lines of code and shift them up. This goes well with the “select word at caret” shortcut. If you want to move a complete if block up by a few lines, select it using ⌥↑ and then shift it up one line at a time using this shortcut. This works better than the usual cut and paste technique if you’re moving up by a few lines. Replace the up arrow with down to shift downwards.
⌃⌥⇧↑ – Previous change
This one is a lifesaver when you stop writing code to figure something out, navigate to a bunch of different files, or follow a method chain, and then forget where you were typing last. Use this shortcut to jump back to the last line of code that you changed. Not only does it take you there, it also shows you a box with the code that you changed.
⌥⌘t – Surround with
Use this to surround a selection of lines with a standard block of code like an if block or a for loop. Saves the time of typing out the block.
Do you have a different top 7? Let me know in the comments.