4

Simple question, I have array:

array(
  'aaa' => 1,
  'bbbbbbbb' => 2,
  'ccccc' => 3,
  'dd' => 4
);

and I want format code to:

array(
  'aaa'       => 1,
  'bbbbbbbb'  => 2,
  'ccccc'     => 3,
  'dd'        => 4
);

Is there a Formatting option to do this, because I don't see anything like this?

PS. Sorry for my English.

4
  • 1
    It's a php array, I don't know why I write this like noob, sorry. Commented Jan 18, 2016 at 11:29
  • replace = with => and then press alt+shif+f to reformat the code Commented Jan 18, 2016 at 11:29
  • I have => in code, alt+shift+f not help me, because this reformatting code to one space before and after => Commented Jan 18, 2016 at 11:31
  • 1
    i think blogs.oracle.com/netbeansphp/entry/… this will help Commented Jan 18, 2016 at 11:45

2 Answers 2

9

PHP code into NetBeans 7.1 In Alignment category there are new properties for Group Multiline Alignment - Assignment and Array Initializer.

enter image description here

On the left site - Assignment property is off and on the right site the property is on. As you can see, when the property is set on, then the assignment char '=' is placed after the longest identifier in a group. The group is defined as a number of lines that contains the same type of assignments. End of a group can be empty line, line where is only a comment, different expression, end of a block. This formatting options works for variable assignment, field initialization and constants.

The second new property is for Array Initializer.

Both properties are switched off by default. Just turn it on and you are done.

Sign up to request clarification or add additional context in comments.

2 Comments

Although, this formats mid-line indentation with tabs, not with spaces. In this case, spaces should be used, because of different tab lengths. But I did not found is this configurable.
Yes. I also want to find this!
5

I am working on NETBEAN for so long, The Best practise is alt+shift+F

1 Comment

yes formating will be done by alt+shift+F but to align array you need to enable it from formatting tab

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.