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

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

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

Eclipse Collapse and Expand All

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

First check folding enable or not.

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

If code always want to collapse by default, You have to follow 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