Intellij-IDEA "Reformat Code" doesn't pickup my settings
Asked Answered
P

4

9

I've used the "reformat code" option but it refuses to format the code to my custom settings. I have changed the "code style" settings in a new template and I'm using it. There is not option to change code style on a global level.

It continutes to format my code like this:

if (x) {
    y();
}

It should look like this:

if (x) 
{
    y();
}

Any thoughts? Just to confirm I have gone into settings and changed the code style in my custom template for the project. I see no global code style option for the IDE settings.

Peltast answered 30/10, 2013 at 14:14 Comment(1)
What language is that? Can you provide a sample project with embedded code style to reproduce this problem?Zamindar
T
5

Code styles are applied on a project level. There is no global setting. You can set a default style via Settings > Other Settings > Default Settings > [Template Project Settings] > Code Style Any new project will use that style.

That said... when you reformat you should get the styles you set. You need to verify that the configuration you created is set in the Settings > [Project Settings] > Code Style --> Scheme dialog. I seen some case where the default is actually reselected by mistake. You may want to double check the specific setting options in that scheme. Make sure the same code that is shown looks exactly like what you want.

Then run a code Layout reformat (Ctrl+Alt+L)

Tanya answered 30/10, 2013 at 14:28 Comment(4)
I've definitely set the project level settings and it's using my custom scheme. But, if what you described is in fact the intended outcome then this is clearly a bug. Either reformat is broken or it's ignoring my custom scheme. I'll look into making a bug report for intellij-idea.Peltast
What was the resolution?Acidfast
What did you see user2936683, what did you see?!?Turbellarian
I was using Java and editing the code style for "Groovy" instead of "Java". Naturally, the Java settings were unaffected. Not sure why this popped up on my feed, but now you know.Peltast
H
4

For me the solution was to disable the EditorConfig support. In Editor -> Code Style

Hydrolysis answered 7/1, 2022 at 17:20 Comment(0)
A
3

For my issue, it's because I installed google-java-format plugin, when it's enabled, it overwrites the code style setting.

Go to Preference -> Other Settings -> google-java-format Settings Uncheck the Enable google-java-format box.

Ambassadress answered 26/10, 2022 at 17:20 Comment(0)
R
1

Your editor may also be inheriting the settings from prettier.

For example, I use WebStorm and no matter what I did, it'd not get formatted according to my settings. I disable the prettier plugin, then my reformat file, and it finally works.

Radiance answered 17/11, 2023 at 16:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.