Question

I've been using PhpStorm (now 7.0.1) for several months now and am more than satisfied, especially with the code formatting. However, even though the auto formatting works very well in PHP and HTML, I just can't figure out how to make PhpStorm automatically align vars from this:

var my_variable = "my value";
var your_variable = "your value";

to this:

var my_variable   = "my value";
var your_variable = "your value";

I've spent hours playing around with the code styling settings but still can't get it done. I would have expected the option Settings > Code Style > JavaScript > Other > Align object properties: On value would be what I'm looking for but unfortunately it does not change anything, neither in the current nor in a fresh project.

Any ideas?

Was it helpful?

Solution

First of all: Settings > Code Style > JavaScript > Other > Align object properties: On value has nothing to do with variable alignment.

Second: This option (Align multiline variable declaration) is NOT available in v7 -- ONLY in upcoming v8.

EAP (Early Access Program) for PhpStorm v8 has already started and option is there. Unfortunately, it is buggy (IDE just hangs straight away when this option is activated). Issue has been fixed already .. but I cannot tell in which of next EAP builds it will be available -- just keep an eye on build number (Help | About) -- it should be 136.1141 or newer.

OTHER TIPS

just adding a thought here on the option Align multiline variable declaration:

This option would NOT give you exactly what you asked for in your question, but what it would do is turn this:

var first = "something",
second = "something else";

...into this:

var first = "something",
    second = "something else";

..which i.m.o. does make more sense w.r.t. formatting. Aligning separate statements (like the two var statements in the question) may not always make sense.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top