'if' statements formatting

Hi
I can't find how to stop IDEA from putting 'if' statement body on the same line. For instance

if (bla)
  foo();


becomes

if (bla) foo();


after reformatting.

Is there any way to make it split it into 2 lines?
Thanks

5 comments
Comment actions Permalink

Hi Konstantin,

Please enable the following code style setting - 'Keep when reformatting - Line breaks'.

Denis

0
Comment actions Permalink

Thanks, but this is a too general setting that affects lots of stuff. Besides, it it simply keeps my own formatting an doesn't make IDEA reformat

if (x) y();


as

if (x)
  y();


I guess there must be a separate setting like 'insert newlines after if/else, do, while, for'

0
Comment actions Permalink

Sure, this one - 'Wrapping and Braces - Keep when reformatting - Control statements in one line'.

Denis

0
Comment actions Permalink

Thanks. I think I was misleaded by the section name and didn't check all the options inside it. "Keep while reformatting" suggests that no action will be taken by reformatter in specific situations, while in this case it actually splits a statement in 2 lines.

0
Comment actions Permalink

On Wed, 07 Sep 2011 02:37:40 MSD, Konstantin Sobolev <k_o_s@mail.ru>
wrote, quoted or indirectly quoted someone who said :

>Is there any way to make it split it into 2 lines?
>Thanks

see File / Settings /  code Style / wrapping and braces
--
Roedy Green Canadian Mind Products
http://mindprod.com
The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is,
the search for a superior moral justification for selfishness.
~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)

0

Please sign in to leave a comment.