Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong array initializer indentation while typing PHP in Eclipse

I set my preferred array initializer indentation on Preferences > PHP > Code Style > Fromatter > Line Wrapping, but while typing array initializers indentation is wrong:

$arr = array([ENTER]
····[CURSOR])

while I'm expecting:

$arr = array([ENTER]
··[CURSOR]
)

like it happens editing Javascript code. Note that the wrong indentation happens only while typing, whereas an explicit CTRL+SHIFT+F indents array initializer correctly. (So not a duplicate of many other questions asking how to set indentation, since here indentation is set but not applied while typing.)

How can I get the correct indentation while typing array initializers?

like image 211
Giovanni Lovato Avatar asked Oct 28 '12 10:10

Giovanni Lovato


2 Answers

My settings on Zend Eclipse for PHP Developers, under PHP > Code Style > Formatter:

  • Indentation > Tab policy > Spaces
  • Indentation > Indentation size > 2
  • Indentation > Tab size > 2
  • Indentation > Default indentation for array initializers > 2
  • Line Wrapping > Expressions > Array initializers > Indentation policy > Indent by one
like image 95
Randell Avatar answered Oct 03 '22 15:10

Randell


Try to set Indentation Policy to Indent by one (instead of Default Indentation) for Method Declarations -> parameters

like image 31
Pigueiras Avatar answered Oct 03 '22 13:10

Pigueiras