PhpStorm – Top Productivity Hacks and Shortcuts

Posted by Unknown on Sunday, February 9, 2014

We all have our favorite IDEs/editors when coding. Mine is PhpStorm, and it took a while to master all its shortcuts and establish a rapid workflow. In this article, I’ll share some keyboard shortcuts and tips with you which you should make part of your regular routine if you, too, do your work in this IDE. This article was partially inspired by this Reddit thread, and will be mentioning and demonstrating some of the shortcuts found there as well.


Note that as I’m doing my development on Linux in a vagrant box hosted on Windows, I’ll be using CTRL instead of CMD. If you’re on OS X, just imagine it says CMD.



Keyboard shortcuts and hacks


PhpStorm’s high configurability (it’s almost an “Android” of the PHP IDE world) lets you fine tune it to infinity – you can make it into a tool so personal, it might seem like a different IDE to anyone opening your settings. Let’s see some shortcuts and hacks we can take advantage of:




  • CTRL + ALT + L, one of my most used keyboard combos, will immediately format your code according to the preferred style guidelines:


    What’s more, as you can see by the popup that appears in the animation above, you can choose to reformat your entire project. If you use this excessively and don’t often work on other people’s projects, you take it up another notch – bind a macro to the CTRL+S shortcut, and make PhpStorm automatically reformat your code on every manual save. Note, however, that if you’re working on a project with someone else, this might cause refactors in various files far too often, and pollute your version control system with changes that aren’t changes at all. If you’re on Linux, your CTRL+ALT+L shortcut might already be bound to “Lock Screen”, and you’ll need to unbind it from the system, or change it in PhpStorm’s settings.




  • Pressing CTRL+SHIFT+Backspace, or the “Forward” and “Back” buttons on your mouse if you have them, will walk you through your previous edit locations. This is very useful when dealing with large files and having to reference another part only to come back to the original to continue the work:




  • Holding down CTRL when hovering over variables or methods will give you their full names or locations of declaration, while CTRL+Clicking on a variable or method, or pressing CTRL+B when on a method’s call or on a variable will take you directly to where it’s defined:




  • CTRL+Space will summon a code hinting dialog, if you accidentally closed it or for some reason it didn’t open:




  • When PhpStorm detects some problems, it will underline the problematic area and summon a lightblub on top of it when you hover your mouse or keyboard cursor in that area. Clicking this light bulb or pressing ALT+Enter will suggest solutions – in any language. This can range from turning off error reports for suppressed notices (something I recommend against), to merging CSS rules:




  • CTRL+N and CTRL+SHIFT+N will let you instantly move to any part of any class or file in your entire project:



    The search is fuzzy, and also supports line numbers – you can use abbreviations followed by :XX where XX is the line number:




  • PhpStorm remembers multiple clipboard contents – you can press CTRL+SHIFT+V to summon a popup which lets you paste clipboard content that’s less recent than the latest.




  • If you’re in love with Sublime’s ability to search for commands of the IDE itself, you can do that too. CTRL+SHIFT+A will spawn a command search popup. Forgot how the code reformat shortcut goes? Just CTRL+SHIFT+A and type “refor..”:




Truncated by Planet PHP, read more at the original (another 9743 bytes)




more

{ 0 comments... » PhpStorm – Top Productivity Hacks and Shortcuts read them below or add one }

Post a Comment

Popular Posts