Stop PhpStorm from aligning associative arrays

2019-01-25 02:06发布

How can I tell PhpStorm 8.0.3 to keep the following array as it is when clicking Cmd+Alt+L to reformat my code:

$array = array(
    'short' => 1, // I want this...
    'veryVeryVeryIncrediblyLong' => 123456789,
);

Instead of doing this:

$array = array(
    'short'                      => 1, // Not this...
    'veryVeryVeryIncrediblyLong' => 123456789,
);

I don't want it to be aligned, because even though generally speaking it is very good, sometimes it doesn't work - such as in huge config arrays, or just to avoid having longer diffs if you have to re-align a full array after adding a new key...

3条回答
Melony?
2楼-- · 2019-01-25 02:33

Preferences → Editor → Code Style → PHP → Other → Align key-value pairs

enter image description here

查看更多
够拽才男人
3楼-- · 2019-01-25 02:36

Settings (Preferences on Mac) | Editor | Code Style | PHP | Other | Array declaration style -> Align key-value pairs

enter image description here

查看更多
来,给爷笑一个
4楼-- · 2019-01-25 02:52

In Phpstorm 2017.3 & later , This setting is located at File | Settings | Editor | Code Style | PHP | Wrapping and Braces | Array initializer | Align key-value pairs

enter image description here

查看更多
登录 后发表回答