Eclipse Gems, Tips & Tricks: Code Folding

This article is part of a ‘mini series’ about hidden gems, tips and tricks around Eclipse.
The topic of this one is how to ‘fold’ text in the editor.

Folded Functions

Folded Functions

With ‘folding’ I can hide/un-hide portions of source in the editor. To use folding, have it enabled in the Window > Preferences:

Enabled Folding in the settings

Enabled Folding in the settings

Little ‘+’ and ‘-‘ in the editor view show up to fold and unfold. The above setting allow to configure what shall be folded/unfolded. Unlike in Visual Studio (C# with the #region … #endregion syntax) it is not possible to fold an arbitrary section. As a workaround I do have ‘Enable folding of preprocessor branches’ enabled. That way I can do the same thing:

Region folding

Region folding

Move the mouse over a ‘+’ shows a preview what is behind:

Unfold preview

Unfold preview

The following shortcuts are very useful to deal with folding:

  • Fold everything: <CTRL>+<SHIFT>+<NUM-KEYPAD-DIVIDE>
  • Un-fold everything: <CTRL>+<SHIFT>+<NUM-KEYPAD-MULTIPLY>

Happy folding 🙂

Links

1 thought on “Eclipse Gems, Tips & Tricks: Code Folding

  1. Pingback: Tweaking MCUXpresso IDE Black Theme | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.