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

Share:
15,830

Related videos on Youtube

StuPointerException
Author by

StuPointerException

Senior Software Developer with over 19 years of experience creating commercial J2EE systems.

Updated on June 20, 2020

Comments

  • StuPointerException
    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
      Tom about 8 years
      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.
    • StuPointerException
      StuPointerException about 8 years
      Ah yes, I'll change the wording of the question to reflect this. Thanks!
    • Basil Bourque
      Basil Bourque over 5 years
  • Marek
    Marek about 7 years
    this will also work if you put an opening brace in new line and want to fold it to {...} instead of latest version of question
  • Traxex1909
    Traxex1909 over 6 years
    One thing to note : You'll have to re-open the file for the changes to take effect.
  • Matthew Read
    Matthew Read over 5 years
    There doesn't seem to be such a path; the other answer works on Mac.
  • Scott
    Scott almost 4 years
    Update: for newer versions of IJ uncheck: File | Settings | Editor | General | Code Folding | Java | One line methods