Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Idea: One line if on two lines

So I am new to the Intellij Idea IDE and so far I like it a lot. Just having some trouble getting the code style settings exactly how I like them for Java. I am a fan of not using braces for one line if statements but I like for them to be on two lines:

if(true)
    dosomething();

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

if(true) dosomething();

and I find that very hard to read, but I cannot seem to get the settings just right. Can anyone help me out and tell me what I need to set to keep it on two lines but still no braces? Feel pretty dumb not being able to find it. Thanks!

like image 587
Evan Frisch Avatar asked Jul 03 '14 23:07

Evan Frisch


People also ask

How do I add multiple lines in IntelliJ?

Press Ctrl+Home to set the caret at the beginning of the first line, enable the column selection mode (press Alt+Shift+Insert ), and then press Ctrl+Shift+End .


2 Answers

Deselect Simple blocks in one line in settings -> CodeStyle -> WrappingandBraces, then it should work. It worked for me.

enter image description here

like image 125
sina72 Avatar answered Oct 06 '22 05:10

sina72


Have you tried Control Statements on one line? Does it for me.

like image 26
Alexandre G Avatar answered Oct 06 '22 05:10

Alexandre G