An Oracle blog about NetBeans for PHP

Formatting - Spaces I

The next  categories, where you can set up the formatting of PHP code is category Spaces. Currently there are implemented more then 40 options that are separated into six groups. All these options as other options, which were mentioned in previous posts about formatting are available in development builds (NetBeans 6.9). The formatting has to be tested properly, if you find a problem, please report it in our database or at least write as a comment here.

The first group Before Keywords defines spaces before a keyword that are usually after '}' char. By default all these properties are switched on. 

The second group Before Parentheses contains options that defines spaces before left parentheses. All options in this group are by default switch on except Method / Function Declaration and Method / Function Call.

The last group mentioned in this post is Before Left Braces. In this group you can define whether the formatting handles space between open brace and an element. All the properties in this group are switched on by default.

Continue the next time.

Join the discussion

Comments ( 12 )
  • bimbo Tuesday, February 16, 2010

    uff too many formating options, this will satisfy everybody :) but it will be nice future if user can select from some predefined formatings, like PEAR, Zend, ...

  • Petr Pisl Tuesday, February 16, 2010

    Too bimbo: It's on my plan. But at first I have to implement more options to satisfy the mentioned styles.

  • Urkman Tuesday, February 16, 2010


    I allready mentioned this in an earlier post:

    it would be great to have an option to add spaces between parentheses like this:

    For functions( calls and definitions ):

    function( $param1, $param2 );

    For Arrays:

    $array[ $value ];

    Hope this will be possible...

    Thanks and greetings,


  • Petr Pisl Tuesday, February 16, 2010

    To Urkman: It's already implemented, it will be mentioned in the next post. Both properties belong to Within Parentheses group.

  • Keith Davis Tuesday, February 16, 2010

    Why does it format one way when I highlight a section of code and select Format, and another way when I format the whole file?

  • Petr Pisl Tuesday, February 16, 2010

    To Keith: Could you write an example? It will be much easier to answer your question for a case. There can be many reasons, why the behavior is different. Also it can be just a bug.

    Because the formatting use also AST for obtaining information, the file should be without errors. And it depends which part of text you select, etc.

  • Franz Liedke Friday, March 5, 2010


    it would be cool, if these settings could be applied to project specific configurations. Without those, the latter don't help much.

  • Petr Pisl Thursday, March 11, 2010

    To Franz Liedke:

    A project can use global option or overwrite with the project setting. So, yes the options can be project specific.

  • Ron Monday, June 21, 2010

    Sometimes I use multiple spaces to make code more readable (multiline strings). In such cases it would be nice to either be able to turn off space formatting or - even better - opt to leave spaces as they are, e.g. for string concatenation.

    Thank you!

  • Buu-Lam Tuesday, August 10, 2010

    Ok with Ron,

    Concerning to assignations, I used to tabulate (with spaces) to align variables, operators and values on several lines. Formatting removes all of preciously added spaces!

    I really need to disable the [Formatting / PHP / Spaces / Around Operators / Assignment Operators].


  • florida cpa Saturday, January 15, 2011

    this is very diffrent from the earlier versions!!

    I was a little disapointment when using the previos versions

  • gkforcare Tuesday, March 29, 2011

    It would be nice if Eclipse settings could be imported so they can be shared between team-members with different taste of IDE.

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.