Minor, but highly annoying, issue with MySQL code identation Follow
Hi all,
So, I'm having this indentation issue when editing MySQL code: any new line subsequent field in the select clause is being indented with 7 chars instead of 4. That 7 would be the size of the "select " text. Same behavior for "where ", "group by ", "order by " etc., that is, for everything that's lengthier than the indent size, 4 in my case.
I need the indent to stick to 4 no matter what. Any idea how can I do that?
Thank you,
Katy
Please sign in to leave a comment.
Hi. Is it in a .sql file or SQL injection in some other language?
In a .sql file.
Do you have this option enabled by any chance?
If not - then please attach a screenshot that would show how the code looks at your end.
That option is not active, I figured it might be involved before posting here. Bellow is the screenshot:
Could you please export your code style scheme as XML (you can do that in the gear icon menu) and share it using the following service? https://uploads.services.jetbrains.com/
Here is the upload ID: 2022_01_14_Rds19NYdscXH8r2w (file: mysql_code_style.xml).
Thank you! Strangely enough, with your code style scheme, I don't get the behavior you describe. After I
The code get formatted exactly as you want it. Please check if these changes help, and if they don't, please double-check that you have the MySQL/MariaDB dialect chosen for the file at Settings | Languages & Frameworks | SQL Dialects.
Well, with you suggestions the select clause works as I want it, but that's the only one working like that. The from, where, order by, group by now they all start from the beginning of the line instead of being indented. Now there is no automatic indentation at all. Don't know which one is worse.
Could you please clarify, what exactly starts from the beginning of the line, the clauses themselves or their elements?
On your screenshot, clauses start from the beginning of the line, I assumed that this was the desired behavior. Do you want them to be indented?
Their elements. I type where, hit ENTER, no indent on the next line. Then I hit TAB, write my first condition, hit ENTER again, I'm at the beginning of the line, again no indent. And this behavior is the same for all other clauses.
I wonder why the behavior I get is so different from yours. For me, with your code style scheme, there is indentation on Enter.
Please try the following:
.idea/codeStyles
folder.Is it any better?
Renamed the codeStyles folder and then started up PhpStorm. No difference at all, still no indenting when ENTER-ing to new line. The thing is that those settings you mentioned early did not change, they are in the same state as before renaming the folder, that is: EditorConfig unchecked and Place clause elements on = New line.
On the other hand, looking at the name of the latter setting, doesn't seem to have anything to do the elements of the clauses but with the clauses themselves, which is not my issue. My issue is the elements not being indented when hitting ENTER for a new line.
Please try settings like this:
Indent with WHERE clause will work if you write like:
No, it's not working, when I hit ENTER after where, there is no indentation, the cursor is at the very beginning of the line. Here are my settings:
Are you on Windows or Linux, btw? I am on Windows. Could that be an issue? I know PhpStorm is written mainly in Java, but I also know that many parts of it are native.
This bug is fixed in next release, please wait for the update. Until that please use 'Reformat code' action, this will align elements as expected.
That sounds good :) Any idea of a release date for the next update? Not asking for an exact date, just a rough estimate.
Thank you.
It's about mid-end of March.
Thanks!