how to align text to specific character in phpstor

2020-05-20 05:52发布

I have this text

$test1 = 'testing1';
$test1test1 = 'testing1';
$test1test1test1 = 'testing1';
$test1 = 'testing1';

and I would like to align it like this, using tabs,

$test1           = 'testing1';
$test1test1      = 'testing1';
$test1test1test1 = 'testing1';
$test1           = 'testing1';

is there a way of doing this in phpstorm or webstorm ?

6条回答
等我变得足够好
2楼-- · 2020-05-20 06:20

For me in PhpStorm 8.0.2 I found it here:

Settings -> Editor -> Code Style -> PHP -> Wrapping and Braces -> Align consecutive assignments

查看更多
smile是对你的礼貌
3楼-- · 2020-05-20 06:27

In PhpStorm 8 that option is in:

File -> Settings -> Code style -> PHP -> Wrapping and Braces -> Assignment statement
查看更多
放荡不羁爱自由
4楼-- · 2020-05-20 06:31

A visual update for 2019.1 on Mac:

Go to PHP Storm > Preferences > Editor > Code Style > PHP > Wrapping and Braces > Assignment Statement > Align consecutive assignments.

To activate it go to Code > Reformat Code or press Cmd+Opt+L.

enter image description here

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2020-05-20 06:36

We have to check multiple options as below to get

  • Problem mentioned above
  • Key value pair alignment of array

enter image description here

查看更多
该账号已被封号
6楼-- · 2020-05-20 06:38

formatting option in phpstorm 8

settings > Code Style > php > Wrapping and braces

enter image description here

check both option Align fields in option and Align Constant

now you can get what you want! :)

Source Jetbrains Blog

查看更多
▲ chillily
7楼-- · 2020-05-20 06:39

Cmd+Alt+L (in Mac) or Ctrl+Alt+L (Win) and PHP Storm will format code depends of your Code style in Settings. TO set this code style go: File -> Settings -> Code style -> PHP(choose here your language) -> Other -> Align key-value pair - mark as checked. And then press Reformat code (Ctrl+Alt+L) and voila. You will get code, styled you write above.

查看更多
登录 后发表回答