I'm trying to setup PhpStorm, so I can simply press: "Reformat Code" ( Option CMD L ), before each save - and then it'll make everything look right.
But I have this case, where I don't know how to make PhpStorm make the code right.
This is the code:
As you can see, then indentation is with tabs, but the aligning of the characters are with spaces.
I want it to look like this:
It would be cool to get the solution. But it would be even cooler to be able to figure out, how I could have found the solution myself.
Further info / idea: There is a Php Codesniffer from Squizlabs implemented. So I can fix is automatically by running a sniff fix
-command. It would be pretty cool, to be able to automatically setup PhpStorm's Code style settings, to correspond with Squizlabs styles, without having to gradually tune the settings one thing at the time. But I haven't found that functionality.
Settings >> Editor >> Code style >> PHP
I couldn't find anything that resembled this.
.editorconfig
I've read quite a bit about .editorconfig
and it doesn't have these nitty-gritty functions here (as aligning equal signs).
But to make sure, I tried disabling it. Didn't make a difference.
But I didn't find anything useful. :-/
I was on PhpStorm version 2022.2.1
.
I tried updating to PhpStorm version 2022.2.4
.
This is still in progress.
Please show what you have at Settings (Preferences on macOS) | Editor | Code Style | PHP
Settings (Preferences on macOS) | Editor | Code Style | PHP
Settings (Preferences on macOS) | Editor | Code Style | PHP
, specifically Tabs and Indents
tab.
Checking Use tab character
option with unchecked Smart tabs
should do just that.
( Pro tip: you can copy-paste your code sample in the preview area and start changing the options; the IDE will apply the changes live on the provided code sample instead of the default one. )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.