0

In My PhpStorm 2019.2.5 is it possible to align some PHP code from

$show_only_top_currencies   = $this->requestData['show_only_top_currencies'] ?? false;
$retArray                 = ['message' => ''];
$currenciesCount          = Currency::getByActive(true)->count();
$base_currency        = Settings::getValue('base_currency', CheckValueType::cvtString, '');

into :

$show_only_top_currencies = $this->requestData['show_only_top_currencies'] ?? false;
$retArray                 = ['message' => ''];
$currenciesCount          = Currency::getByActive(true)->count();
$base_currency            = Settings::getValue('base_currency', CheckValueType::cvtString, '');

?

and same for JavaScript code?

1
  • Did you try switching "Variable declarations" to "Align: When grouped" in "Editor | Code Style | JavaScript" already? Commented Feb 3, 2021 at 9:19

1 Answer 1

1

Yes, that's possible for PHP code: the setting is called "Align consecutive assignments". This is where you can find it in PhpStorm 2020.3.2:

enter image description here

A similiar setting can be found for JS code, "Variable declarations: Align when grouped".

You can fiddle around with both settings and see the effect in the code snippets - this might help to find other helpful options

Sign up to request clarification or add additional context in comments.

5 Comments

I tried to find this option under Setting and failed. Next was opened : prnt.sc/yeb67r Could you please to check if this option is in my PhpStorm 2019.2.5 ? Actually, I expected something like : I select rows of text and by some menu action(hot key) aligmnent is applied. Are there something like that ?
Sorry, I'm using 2020.3 - I've attached a screenshot
Looks like my PhpStorm 2019.2.5 has no this functionality ?
@mstdmstd Of course it's there. Here is an answer from 2016 for PHP: stackoverflow.com/a/39287563/783119 For JavaScript (from 2014): stackoverflow.com/a/22360509/783119 .
@mstdmstd "I expected something like : I select rows of text and by some menu action(hot key) aligmnent is applied." If you need that then try string related plugins, I remember seeing a few where description says that they can format tabular data (which is what an alignment is in an essence). Start with String Manipulation plugin (Sort Tokens action I believe).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.