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

On clicking + icon, Expand the code block, - the 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 enables or not.

  • CTRL + / Folding enabled or disable 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 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