Hiding Inactive Code In Eclipse

In many sources I have ‘inactive’ code: source code which is disabled by some macros or defines. Eclipse is great to ‘gray’ out the inactive parts using its Indexer, but they still need screen real estate:

Inacitve Code in Eclipse

inactive Code in Eclipse Source View

To hide these sections of ‘inactive’ code, I can use the built-in source folding feature. The setting is under Window > Preferences > C/C++ > Editor > Folding:

Hiding Inactive Preprocessor Branches

Hiding Inactive Preprocessor Branches

With initially folding ‘Inactive Preprocessor Branches’ the inactive parts are now folded by default. They still need one line, and I can unfold the sections if needed:

Folded Inactive Code

Folded Inactive Code

Happy Hiding πŸ™‚


6 thoughts on “Hiding Inactive Code In Eclipse

  1. Sometimes it’s these little things that make work so much more productive and fun. I also love many of the sophisticated editing key shortcuts Eclipse offers. Very handy!
    Thanks for sharing!


  2. How many time did I spend for scrolling up and down my code without finding what I search ! Now is quick and easy. Great feature. Thank you, you make my day Eric ! πŸ™‚


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 )

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.