No, this is not about how to fold Eclipse: it is about the Folding feature of the Eclipse editor view. My source files tend to get much larger than a single screen page. The Eclipse framework comes with many great editor and navigation features, but it would be great to have the amount of information reduced. Well, it can look like this:
Yes, this shows about 140 lines of code in a condensed way . It gives me the high level picture. I can dive into the details on demand. What I’m using here is the Eclipse feature of Folding. Note the small + and - signs on the left side of the view: this is used to fold/unfold regions in the editor.
To toggle folding, I use the Ctrl+Numpad_Divide command. I can use the command as well with Ctrl+3 (see The Mother of all Eclipse Shortcuts):
Note: In case Numpad_Divide is not easily accessible on my keyboard layout, the key bindings can be changed under the menu Window > Preferences > General > Keys.
‘Toggle Folding’ just enables folding for the current editor view. By default it is not enabled when I open a new editor view. I can change and configure this. I go to the menu Window > Preferences and go the ‘Folding’ setting page as below: here I can configure the level of folding:
I can fold/unfold portions in my source code like below which greatly improves readability:
To have a sneak preview what is inside a folded region, I do not need to unfold it: I simply move my mouse cursor over the + and a hover text will show what is behind it:
Folding makes it easy for me to navigate through big chunks of source files and to focus on the parts which are important. It saves me a lot of scrolling or navigating around.
Happy folding and unfolding
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)