Eclipse Code editor has an option left side +/- icons beside line number on functions and code blocks.

On clicking the + icon, Expand the code block, - icon collapses the code block.

The expand and collapse icons are added to comments, functions, and blocks.

Eclipse Collapse and Expand All

There are shortcuts to collapse and Expand all in the Eclipse code editor.

First, check whether folding is enabled or not.

  • CTRL + / Folding enabled or disabled using toggle switch
  • Ctrl + * : expands code block After folding is enabled, The below command works
  • Collapse All -> Ctrl + Shift + /(Numpad Divide)
  • Expand All -> Ctrl + Shift + *(Numpad Multiply)

If the code always wants to collapse by default, You have to follow the below steps

  • Windows Menu > Preferences, Window dialog shown.

  • Search Folding in input and select Folding in Java > Editor

  • Check all options

    • Enable Folding
    • Initially fold these elements
      • Comments
      • Header Comments
      • Inner Types
      • Members
      • Imports