Emacs Tip of the Day # Collapsing Functions #


So, you’ve opened the CPP file you are working on. For the moment, you just want to see all the functions that have been defined, to get an idea of the functionality provided. But your file is 102KB. If only there were some way you could collapse all the code!

*blaring trumpet sounds* EMACS to the rescue!

Simply fire up a mode called outline-minor-mode. M-x outline-minor-mode

Now, to collapse the code, hit M-x hide-other. Voila!

When you find the function you were looking for, you might want to read the code for it. Hit M-x show-subtree.

Finally, to expand all of the code back again, hit M-x show-all

That is all folks!

This blog is increasingly getting to be an Emacs blog! This is what happens when a geek is separated from his beloved Unix environment and has only Emacs as consolation. Since I code in C/C++ at the workplace, I’m now planning to write a bit about Object Oriented Programming. Or some such things šŸ™‚



3 Responses to “Emacs Tip of the Day # Collapsing Functions #”

  1. Peter Says:

    Thanks for all your emacs posts! I’m just beginning to use it, and I find your little tid bits very useful.

  2. hanjunxian Says:

    What a simple and effective way! I’ve been looking for a solution like that. Thanks so much.

  3. jchouinard Says:

    This rocks — thanks! Also, good title. It came right up since I searched for “Emacs Collapsing Functions”

Leave a Reply

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

%d bloggers like this: