jithink
jithink

Reputation: 21

Formatting in netbeans?

I want to know how can I configure my netbeans ide to format my code in my specific need. I need all my assignment in same line to easily distinguish it. for eg:

 $a    = 1;
 $b    = 1;
 $c    = 1;
 $a++;
 some code

 $d    = 1;

Upvotes: 1

Views: 532

Answers (2)

skomisa
skomisa

Reputation: 17383

Based on your sample code, I'm assuming that you want to do this for PHP. If so, then you can do it as follows:

  • Select Tools > Options > Editor, then click the Formatting tab.
  • Select PHP from the Language drop list, then Alignment from the Category drop list.
  • A code sample will be displayed in the Preview window on the right side of the screen which includes some variable assignments near the end of the code:

    withoutAlignment

  • Under Group Multiline Alignment check the Assignment box. Note that the assignment operators (=) in the code preview are now aligned:

    withAlignment

Notes:

  • The column position used for aligning the assignment operators is dynamic, based on the length of the longest variable name. I don't think it is possible to place the assignment operator in a specific column as suggested by your code example.
  • This approach is specific to PHP, and can't be used for formatting code in other languages such as Java or JavaScript.

Upvotes: 2

Joachim Rohde
Joachim Rohde

Reputation: 6045

Formatting in NetBeans can be configured under "Tools / Options / Editor / Formatting", but I don't think that you can configure NetBeans to use your desired format.

Upvotes: 0

Related Questions