6

我在 Preferences > PHP > Code Style > Fromatter > Line Wrapping 上设置了我的首选数组初始值设定项缩进,但是在键入数组初始值设定项缩进时是错误的:

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

虽然我期待:

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

就像它发生在编辑 Javascript 代码一样。请注意,错误缩进仅在键入时发生,而显式 CTRL+SHIFT+F 会正确缩进数组初始值设定项。(所以不是许多其他询问如何设置缩进的问题的重复,因为这里设置了缩进但在键入时不应用。)

如何在键入数组初始值设定项时获得正确的缩进?

4

4 回答 4

4

我在 Zend Eclipse for PHP Developers 上的设置,在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
于 2013-10-31T09:41:46.740 回答
3

尝试将缩进策略设置为Indent by one(而不是Default IndentationMethod Declarations -> parameters

于 2012-10-28T11:32:55.513 回答
2

在 Eclipse Juno 中,尝试使用 PHP -> Code Style -> Formatter -> Default indentation for array intializers = 1。它适用于我。

于 2013-01-10T22:46:30.780 回答
2

在我的 Windows 实例中,必须重新启动 Eclipse 才能应用对此设置的更改:

PHP > Code Style > Formatter > Default indentation for array intializers

在其他情况下,它不是必需的。不知道为什么。

于 2016-03-24T11:21:23.287 回答