Is it possible to condense a large source file by folding/unfolding different portions of code?

Yes, you can enable folding in editor and specify levels of folding and which portion of code needs to be folded. To enable and configure folding/unfolding, perform these steps.

  1. From the IDE menu bar, select Window > Preferences.

    The Preferences dialog box appears.

  2. Type folding as the filter text to narrow down the list of preferences.
  3. Select C/C++ > Editor > Folding. The Folding preference page appears in the right panel of the Preferences dialog box.
    Figure 1. Folding Preference Page

    Folding Preference Page

  4. Check the Enable folding when opening a new editor checkbox.
  5. Configure level of folding and select which regions of code should be automatically folded.
  6. Click OK and reopen your source file.

Now you can fold/unfold portions in your source code, as the figure listed below shows. The fold/unfold functionality is added with new markers (+/-) at the left side in the source file. This improves readability of the source code.

Figure 2. Editor With Folding Enabled

Editor With Folding Enabled

To preview what is inside a folded region, you do not need to unfold it again. Hover your mouse cursor over a folded region and a popup appears displaying the details.

Figure 3. Folded Region Preview

Folded Region Preview