A Nice Folding Trick for Emacs

jao over at Minor Emacs Wizardry has a nice post on folding in Emacs. As he points out, there are several packages to do folding but there is also a built-in method that may handle many of the cases where you want folding. The command set-selective-display will cause any lines with an indentation greater than or equal to its argument to be hidden. This is useful (depending on your coding style) when you want to see only function headers and global data declarations. You need only call set-selective-display with an argument of 1.

The command is bound to 【Ctrl+x $】 so you can hide everything but your top level definitions by typing 【Ctrl+1 Ctrl+x $】. To turn off the folding, just call 【Ctrl+x $】.

You may find the key sequence a little clumsy, so jao offers a couple of short cuts. It’s a nice post so you should take a look if you have an interest in this sort of thing.

This entry was posted in General and tagged . Bookmark the permalink.