IntelliJ collapsing single line methods
Asked Answered
A

3

104

Since I've updated my version of intelliJ (14.x to 15.x) it has started automatically collapsing single line methods in the Java editor:

Previous version:

public void setContext(SecurityContext context) {
    this.context = context;
}

Latest version:

public void setContext(SecurityContext context) { this.context = context; }

Is there a way to prevent this? I find the original version much easier on the eyes!

Thanks.

Arabinose answered 14/3, 2016 at 18:18 Comment(3)
I don't think it formats this code, it just collapses it. When you look on the left border of the code view, there should be a small "+" sign to expand it, like for the import block.Governorship
Ah yes, I'll change the wording of the question to reflect this. Thanks!Arabinose
See duplicate: IntelliJ IDEA one-line function formattingMetrify
S
161

Open 'Settings' from the File menu. Under 'Editor' -> 'General' -> 'Code Folding', you will find a 'Collapse by Default' section.

Simply uncheck 'One-line methods' and click OK.

enter image description here

Semifinalist answered 14/3, 2016 at 18:34 Comment(3)
this will also work if you put an opening brace in new line and want to fold it to {...} instead of latest version of questionOrchidaceous
One thing to note : You'll have to re-open the file for the changes to take effect.Benefit
Update: for newer versions of IJ uncheck: File | Settings | Editor | General | Code Folding | Java | One line methodsDerogate
C
11

On Windows:

Settings -> Editor -> General -> Code Folding -> Uncheck "One-line methods"

Coaptation answered 19/6, 2019 at 13:23 Comment(0)
B
2

For mac, Code > Folding > Expand ALL/To Level

Burress answered 23/9, 2018 at 1:13 Comment(1)
There doesn't seem to be such a path; the other answer works on Mac.Motoneuron

© 2022 - 2024 — McMap. All rights reserved.