IntelliJ collapsing single line methods
15,830
Solution 1
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.
Solution 2
On Windows:
Settings -> Editor -> General -> Code Folding -> Uncheck "One-line methods"
Solution 3
For mac, Code > Folding > Expand ALL/To Level
Related videos on Youtube
Author by
StuPointerException
Senior Software Developer with over 19 years of experience creating commercial J2EE systems.
Updated on June 20, 2020Comments
-
StuPointerException almost 4 years
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.
-
Tom about 8 yearsI 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. -
StuPointerException about 8 yearsAh yes, I'll change the wording of the question to reflect this. Thanks!
-
Basil Bourque over 5 yearsSee duplicate: IntelliJ IDEA one-line function formatting
-
-
Marek about 7 yearsthis will also work if you put an opening brace in new line and want to fold it to
{...}
instead oflatest version
of question -
Traxex1909 over 6 yearsOne thing to note : You'll have to re-open the file for the changes to take effect.
-
Matthew Read over 5 yearsThere doesn't seem to be such a path; the other answer works on Mac.
-
Scott almost 4 yearsUpdate: for newer versions of IJ uncheck: File | Settings | Editor | General | Code Folding | Java | One line methods