Intellij Idea: one line if two lines

So, I'm new to the Intellij Idea IDE, and still enjoy it a lot. I just had problems with the code style settings exactly as I like them for Java. I'm a fan of not using curly braces for one line if statements, but I like them to be on two lines:

if(true) dosomething(); 

Right now, when I run the code formatting in Idea, it moves up one line:

 if(true) dosomething(); 

and I find it very difficult to read, but it seems like I can't configure the settings correctly. Can someone help me and tell me what I need to keep it on two lines, but still no braces? You feel pretty stupid, unable to find him. Thanks!

+8
java intellij-idea ide
source share
4 answers

Deselect Simple blocks in one line in the settings β†’ CodeStyle β†’ WrappingandBraces, then it should work. It worked for me.

enter image description here

+6
source share

Have you tried the control messages on one line? This is for me.

+4
source share

Well, this may seem strange, but even I had the option simple blocks in one line unchecked. And I faced the same problem. But then, if I left one empty line after opening the method bracket, IntelliJ did not move all the code to one line.

For better understanding,

  • Problem behavior

     public void methodA(){ System.out.println("No blank line left"); } 

    Now when you close and open the file again, IntelliJ does this

     public void methodA(){ System.out.println("No blank line left"); } 
  • Correct behavior

     public void methodA(){ System.out.println("left a blank line above"); } 

    Now, when you close and open the file again, it still remains so

     public void methodA(){ System.out.println("left a blank line above"); } 

To take note, IntelliJ version is Ultimate 14.1.4

0
source share

For Webstorm - IntelliJ for Javascript, this parameter is located in Preferences->Editor->Code Style -> Javascript-> Wrapping and Braces .

0
source share

All Articles