5

In PhpStorm is it possible to have the auto formatter align consecutive assignments in JavaScript? The PHP formatter has the option to align on equals ("+") by checking the "Align consecutive assignments" option in Settings -> Code Style -> PHP -> Other(Tab), but there doesn't seem to be that option for JavaScript, just for colon assignments.

I am using PhpStorm 7.1.3, the latest at the time of writing.

Thanks.

1
  • 1
    I believe you need v8 for that -- there are some improvements in this area. You can try EAP build here: eap.jetbrains.com/phpstorm Commented Apr 17, 2014 at 14:29

1 Answer 1

7

I am using phpstorm 2018.3.5 and I just had to configure this style of alignment for a project I took over.

As sam said here for php you can set it in :

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

So I thought it would be the same for JS but it turns out to be slightly different :

Settings -> Editor -> Code Style -> JavaScript -> Wrapping and Braces -> Variable Declarations -> Align -> When grouped

I hope this can help.

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

2 Comments

"Align consecutive assignments" is not there (incidentally, neither is "Variable Declarations -> Align -> When grouped" for PHP either in case you were wondering if it happened to match a JS setting). I'm using PhpStorm 2024.1.4 on Windows 10 Pro. I'm not seeing what does it yet, and I'm using the IDE's "Set from" WordPress editorconfig. Ironically the column-based alignment isn't even a WordPress formatting standard, so it's maddening that PhpStorm seems to be forcing something WordPress's developers should be disabled by default and that most devs dislike anyway.
I'm thinking the .editorconfig setting for this (should you not find it in Settings) is ij_php_align_assignments. However, this doesn't seem to take effect after edit-save, and I'm not seeing how to auto-reload the file. It only takes effect after re-opening the project :/ Oddly, JetBrain's documentation says each line in .editorconfig has a corresponding Code Style setting, but I'm not seeing which one corresponds there.

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.