How to change brace position in IntelliJ IDE?

17

3

I am using the IntelliJ IDEA ide for java coding. By default it produces curly braces on the same line as the function name, like so:

function bla() {
..
}

Can i change it somewhere there so that i will do this instead?:

function bla() 
{
..
}

Thanks!

user3595338

Posted 2014-08-02T16:28:09.443

Reputation: 273

Answers

24

From the IntelliJ documentation:

Go to the menu File | Settings | Project Settings | Code Style - Java. Select the 'Wrapping and braces' tab. Set 'Braces placement options' to 'Next line'.

tcmb

Posted 2014-08-02T16:28:09.443

Reputation: 368

I had to go to File > Settings then search for Code Style in IDEA 2016.1. – Steve HHH – 2016-05-19T19:30:35.983

1Preferences > Editor > Code Style > Java is another route, at least in 2016.2. – Flimbus Akimbo – 2016-08-03T19:34:48.343

didn't worked for me (yes, I copied the new style into the Project's) – Yar – 2016-08-12T20:08:56.773

what i want is curly brace at end of function name and then a newline, e.g. function foo(){ \n\n – Toskan – 2016-08-30T07:24:56.997

Is it possible to update existing code with new rules? This worked for me when writing new code, but not any old code. Link

– Mike Chase – 2020-01-28T00:28:31.183

2

Here is the exact working path. I have added screenshot with explanations.

Screenshot "How to change braces position in Intelli

George

Posted 2014-08-02T16:28:09.443

Reputation: 31