Configuring Netbeans for WordPress Coding Standards

By default, Netbeans is mostly configured to format code in the way that matches the WordPress Coding Standards, except for the spacing within parantheses. You can edit them under Tools → Options → Editor → Formatting → Language = PHP → Category = Spaces. Here’s a screenshot of the correct settings (click to enlarge):

Netbeans PHP spaces

You can also amend the PHP (and All Languages) tabs and indents to match the following, if it’s not already:

Netbeans - PHP tabs and indents

Now, any time you need to match the formatting, you can select all the text, then hit ALT-SHIFT-F (or right-click → Format). The only one it doesn’t seem to catch is the negation operator (!), so you’ll still manually need to turn:

if ( !foobar ) {

into:

if ( ! foobar ) {

Speak Your Mind

*