Timesaving Phpstorm Keyboard & Mouse Shortcuts to Increase Productivity
Some developers will pass over PhpStorm (or other JetBrains products) because it doesn’t embody the same look and feel of a typical Mac application, which is unfortunate. PhpStorm is a powerhouse packed with productivity boosting features, that once you use them, you will never be able to use a standard text editor again.
I know that most text editors do have a wealth of plugins that offer some of the same functionality below, but in my experience, the implementation and execution of those plugins usually do not match in quality to what PhpStorm offers out of the box.
Not to mention everything below comes baked into PhpStorm and works consistently, without having to scour the internet to find these plugins or worry about their ongoing support.
Keyboard Shortcut Legend
Just so we’re all speaking the same language... Below are the keyboard symbols used in the rest of the article so we know what they mean.
- Command: ⌘ on Mac
- Alt / Option: ⌥ on Mac, Alt on Windows
- Control: ⌃ on Mac, Ctrl on Windows
- Shift: ⇧ on Mac, Shift on Windows
- Enter: ⏎ on Mac, Enter on Windows
- Delete: ⌫ on Mac
- Up Arrow: ↑ on Mac, Up on Windows
- Down Arrow: ↓ on Mac, Down on Windows
Default Keyboard Shortcuts
Ok. With All that out of the way, below are the default keyboard shortcuts that ship with PhpStorm.
Reveal Tool Windows
- Mac: ⌘⌘ (Double Press / Tap and Hold)
- Windows: Alt + Alt (Double Press / Tap and Hold)
Starting in PhpStorm 7, I believe, JetBrains decided to hide the Tool Windows, by default, to declutter the UI. To reveal the Tool Windows on the sides and bottom of IDE, just double press / tap the command keys.
- Mac: ⌘⇧A
- Windows: Ctrl + Shift + A
Find Action is like the super keyboard shortcut. You can use it to search for shortcuts and IDE actions (aka. things you can do that don’t even have keyboard shortcuts). This is helpful for discovering shortcuts you don’t already know or for jogging your memory by typing in a keyword or phrase.
- Mac: ⌘⇧O
- Windows: Ctrl + Shift + N
Navigate File is just a fancy name to mean "open files".
Navigate File also support searching for files with wildcards, title case, file extension, etc..
- Mac: ⇧F6
- Windows: Shift + F6
Using this, you can rename practically anything, such as variables, functions, filenames, class names, html tags, etc. This even works for some more obscure languages you wouldn't expect, like Less / Sass, Mustache, and PHPDoc, to name a few.
Not only that, but it will automatically refactor all places these things are within the entire project.
Show Intention Actions
- Mac: ⌥⏎
- Windows: Alt + Enter
This is a super fancy name for "fix problems". Show Intention Actions is for anything from fixing typos / spelling, to fixing incorrect parameters, to automatically updating your PHPDoc if you change parameters, and much, much more.
Use this wherever you see a yellow or red squiggly line underneath something.
- Mac: ⌥F12
- Windows: Alt + F12
Yes, PhpStorm has a fully functional Terminal baked right into it. This is incredibly handy, especially when you're using tools like NPM, Grunt, Gulp, Composer, etc. in your projects. Mash ⌥F12 and you're there, ready to rock a command.
No context switching, no fumbling for the right window. Just seamless productivity.
- Mac: ⌘N
- Windows: Alt + Insert
Use the New command when you have a folder selected in the project window and you can insert / create a new files and folders.
You can even create nested files and directories with the same command.
Find in Path
- Mac: ⌘⇧F
- Windows: Ctrl + Shift + F
Find In Path will search your entire project for just about anything.
You can refine scope to a particular folder, do a reclusive search, match case, regex, etc. A crazy amount of search power for such a little window.
And if you have anything selected, that will automatically become the search term.
Paste from History
- Mac: ⌘⇧V
- Windows: Ctrl + Shift + V
This is also known as Clipboard History.
This keeps a running log of things you’ve copied within PhpStorm and you can use it pretty much anywhere within PhpStorm, including the find / replace fields, extracting variables, extracting methods, renaming, etc.
I believe the default history limit is set to 5, which is weak.
Just navigate to
PhpStorm > Preferences > IDE Settings > Editor > Maximum number of contents to keep in clipboard to up that limit to something more respectable. I have mine set to
Move Line up / down
- Mac: ⌥⇧↑ and ⌥⇧↓
- Windows: Alt + Shift + Up and Alt + Shift + Down
These shortcuts move whatever line of code the cursor is on up or down a single line.
Very handy for changing the order of an array or declared variables. And most times, it will even shuffle the commas around appropriately too!
Move Statement up / down
- Mac: ⌘⇧↑ and ⌘⇧↓
- Windows: Ctrl + Shift + Up and Ctrl + Shift + Down
These work much like the Move Line Up / Down shortcuts, but these will move whole statements up or down a single line.
Think along the lines of entire functions, objects, or arrays instead of just a single part of those things.
- Mac: F7 (Step Into), F8 (Step Over), and ⌥⌘R (Resume)
- Windows: F7 (Step Into), F8 (Step Over), and F9 (Resume)
Once you setup and launch a debugging session, I use these shortcuts to navigate through the code with ease.
Extend / Shrink Selection
- Mac: ⌥↑ and ⌥↓
- Windows: Ctrl + W and Ctrl + Shift + W
These shortcuts will gradually increase or decrease what you have selected, at logical breaking points, and even within strings!
This is one of those features that wish was available in any application or operating system once you start to use it.
- Mac: ⌥⌘V
- Windows: Ctrl + Alt + V
Extract Variable works by taking whatever you have selected and creating a new variable out of it.
This even works for Less / Sass variables too!
- Mac: ⌥⌘M
- Windows: Ctrl + Alt + M
Extract Method works by taking whatever you have selected and creating a new method / function out of it, including any necessary parameters.
- Mac: ⌥⌘N
- Windows: Ctrl + Alt + N
Inline is the opposite of the extract shortcuts mentioned above.
It will take variables and methods and will bring them back inline where they are in use.
Duplicate Line or Block
- Mac: ⌘D
- Windows: (unknown)
This shortcut will duplicate the line of code the cursor is on, if nothing is selected.
If something is selected, it will duplicate whatever is selected.
- Mac: ⌘⌫
- Windows: Ctrl + Y
This shortcut will remove the line of code the cursor is on, if nothing is selected.
If something is selected, it will remove whatever lines are selected.
- Mac: ⌃Space
- Windows: Ctrl + Space
This feature pretty standard in most apps, but even though it's such a common feature, I still use it every single day, so it's worth the mention.
Code Completion works by offering suggestions for variables and methods to complete what you have partially typed.
Most of the time, this will just work on its own, but if you're typing really fast, then you can explicitly invoke it with the shortcut.
Custom Keyboard Shortcuts
Those defaults are all well and good, but what if you want to change or customize your keyboard shortcuts? What if you want to create new keyboard shortcuts for features you use within PhpStorm that don’t have a keyboard shortcut defined?
No problem! PhpStorm has this covered in what they call Keymap. Just navigate to
PhpStorm > Preferences > IDE Settings > Keymap to uncover all the goodies.
In the Keymap, you can search for actions by their name or by their assigned keyboard shortcut.
For example, I use the Split Vertically action all the time, so I can have two editor windows open at the same time, usually when I want to write some markup and some styles at the same time. This is such a huge timesaver to have either file accessible as I am building things out.
Split Vertically doesn’t have a keyboard shortcut by default, so add it to the Keymap, and you’re ready to go! I chose ⌃⌥⌘V as my Split Vertically shortcut.
Don’t worry if you use something that is already defined as a shortcut. PhpStorm will let you know and ask you if you want to remap the keys.
I know that sounds weird, but hear me out.
There are a couple of mouse shortcuts I want to point out that I find incredibly handy.
Hide / Reveal Tool Windows
Once you get cranking away, the IDE can get pretty busy with all kinds of panels, files, terminals, etc. open and now you want to eliminate all the distractions and you want to see as many lines of code as possible.
Just double-click any editor tab to hide all the open Tool Windows. And double-click again to bring them all back.
Redistribute Editor Windows
When I have multiple editor windows open, I am constantly moving things around, resizing the windows to give me the most space on what I am working on the most, but now I want to have them be evenly spaced again.
Simply double-click on the space between the split editors to evenly redistribute them.
Once you get the hang of these shortcuts, you’ll feel and incredible source of power and confidence, especially when refactoring. And you’ll wonder why you waited so long to ditch your text editor of choice for a fully functional IDE.
Have a question about this post or anything else?