Netbeans 7.0 for PHP – Keyboard shortcuts

Netbeans 7.0 PHP IDE EDITORNetbeans PHP 7.0 includes a powerful refactoring tool, support for PHP aliases and PHPDoc generation (not tested yet). I think when xdebug watching feature will become stable, Netbeans  Рcurrently my favourite Рwill be a fully-featured PHP IDE, probably the best free alternative to Zend Studio.

Netbeans PHP was initially created for Java and afterwards ¬†extended for PHP development, so most of the code OOP features are unknown by PHP community. I haven’t found a page containing a full description of them, so I’ll list here some shortcuts/features I found very useful.

Be smart ! Spend some time learn and experiment them, and you will save lots of time later doing more proper developing, less bug fixing, and less click/search actions. Depending on the tasks, even one of them can considerably increase your performances.

Code navigation
Ctrl+Click on a method/class/function go into the class (if it’s a dependent project/libraries, add those in the project properties)
Alt+Left, Alt+Right navigate back/forward when using the ctrl+click feature
Autocompletition
Ctrl+Space when typing code (variable, method, function, class name,…) => show autocompletition with PHP Docs
Ctrl+ [mouse over] shows the PHP Doc of the method (another reason why it’s necessary to write PHP Docs for our methods/classes)
Ctrl+K/L immediate autocomplete with first match (rotate)
Refactoring
Ctrl+R on a selected variable : automatically highlights all the occurrences in the scope and when typing the changes, it changes all of them
Ctrl+R on a method/class :show a dialog with the new name, and refactors all the occurrences around the code (Implemented in NB 7.0). Of course netbeans does a refactoring using names, it cannot consider dynamic instantiation of classes.
Code generator
Alt+Ins : autcompletition of class constructor, setter and getter methods using existing class fields
Lines editing
The following commands are extremely useful when dealing with zend configuration INI files, chain calls to methods or array options)
Ctrl+E delete line
Alt+Shift+Up / Down move the current line or selection one line up/down
Ctrl+Shift+Down duplicate line
Ctrl+G go to line number
Format
Shift+Tab / Tab on group of line, move tabulation of all the selected line to the left/right (obvious but not everyone knows)
Alt+Shift+F Format/Ident the selected code (not code-sniffer-proof but an order of magnitude better than doing it manually)
Windows Management
Ctrl+w close current window
Menu: Windows->Reset Windows restore windows
Shift+Esc or Double click on a file tab: expand to fullscreen (double click again to go back)
Ctrl+Tab shows opened files list (keep Ctrl button pushed and push Tab to rotate)
Ctrl+Page up/down rotate opened file tabs
Code suggestions
Netbeans highlights syntax errors, and also suggest tips on the line number column, use Alt+Enter to see and select automatic fixes
Bookmark
Ctrl+M set/remove a bookmark on the current line (an icon is displayed)
Ctrl+, move to the next bookmark (rotate)

 

You can see all the shortcut list in Netbeans options, but it’s not clear what they do and most of them are not really useful. An interesting feature is assigning shortcuts for custom commands (e.g. git commit).

I’ll keep this post updated

 

4 thoughts on “Netbeans 7.0 for PHP – Keyboard shortcuts

  1. The same for single line, Ctrl+Shift+C, search in the keywords associations nb tab. select the lines you want before or it works on the current line

Comments are closed.