Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA one-line function formatting

IntelliJ keeps formatting this:

public void addElement(Element elem) {     this.elements.add(elem); } 

into this:

public void addElement(Element elem) { this.elements.add(elem); } 

I prefer the multi-line formatting. How can I tell this to IntelliJ? I have unchecked the following boxes in Settings -> Editor -> Java -> Wrapping and Braces

  • Control statements in one line
  • Simple blocks in one line
  • Simple methods in one line

Didn't help.

like image 496
Atte Juvonen Avatar asked Mar 29 '16 20:03

Atte Juvonen


People also ask

How can I beautify code in Intellij?

Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).

How do I arrange lines in Intellij?

Rearrange codePress Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. In the editor, select the code entries you want to rearrange and from the main menu, select Code | Rearrange Code.

What is the shortcut key for format in Intellij?

You can use ⌘⌥L (macOS), or Ctrl+Alt+L (Windows/Linux) to reformat a selection of code according to your reformat settings.

How do I turn off auto format in Intellij?

In Preferences > Editor > Code style > [language] uncheck reformat on file save .


1 Answers

Look in Preferences (or Settings), Editor, General, Code Folding, Collapse by default, One-line methods

enter image description here

like image 105
Kirby Avatar answered Sep 22 '22 07:09

Kirby