IntelliJ IDEA one-line function formatting

2019-02-05 10:48发布

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.

2条回答
男人必须洒脱
2楼-- · 2019-02-05 11:23

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

enter image description here

查看更多
乱世女痞
3楼-- · 2019-02-05 11:41

below is the shortcut for Merge multiple lines into a line -

Ctrl+Shift+J

查看更多
登录 后发表回答