Devwulf
Devwulf

Reputation: 410

Android Studio/IntelliJ - Curly braces doesn't go to new line even with proper settings

In Editor > Code Style > Java, I currently have my Braces placement settings to "Next Line" for In class declaration, In method declaration, and Other. Yet when I create a new method and press Enter between the two braces: { <here> }, the closing brace gets properly formatted but the opening brace still stay on the same line as the method declaration, like so:

public void Test() {

}

but I want it to auto format to this instead:

public void Test()
{

}

Am I missing a setting that I should change? If it matters any, I'm using Android Studio 2.3.3.

Thanks!

Upvotes: 2

Views: 3877

Answers (2)

Shaybc
Shaybc

Reputation: 3147

apparently some one at Google decided to act like Microsoft and try to force their opinion on the rest of us and disabled the ability to reformat the coed (almost) at all,

check their FAQ regarding Dart formatter at: https://github.com/dart-lang/dart_style/wiki/FAQ

Can't format Dart

i suggest using a different IDE (funny enough like MS Visual Studio Code)

I always thought that the IDE's responsibility is to allow each person style his/hers code the way their brain can process it easily and fast recognize the code parts (hence styling and coloring code),

a nice feature would be the ability to see the code in the IDE the way we like it, but when saved to git - reformated to a general / company standarts, and when the code is loaded from the git it should be auto reformat to the way my IDE is set to display it

uniqueness and diversity should be celebrated and not forced into darker days rules where we are all the same

Upvotes: 0

glytching
glytching

Reputation: 47905

From Editor > Code Style > Java > Wrapping and Braces go to:

  • Braces placement
    • In method declaration: Next line

Here's an example screenshot:

enter image description here

IntelliJ will leave the opening brace on the same line when you hit ENTER but if you reformat that class then IntelliJ will apply your chosen format resulting in the opening brace being moved onto the next line. You can reformat your code from the menu: Code > Reformat Code or have a look at Preferences > Keymap > Main Menu > Code > Reformat Code to see the keystroke combination for applying the formatter.

Upvotes: 5

Related Questions