Difference between revisions of "Tip 12: Collapsing Code"

From Vlsiwiki
Jump to: navigation, search
(Created page with 'Once you have a bunch of code, it becomes difficult to navigate. Before, I showed that you can use Tip 7: etags to do this , but there is also another way: collapsing code. …')
(No difference)

Revision as of 16:33, 22 June 2010

Once you have a bunch of code, it becomes difficult to navigate. Before, I showed that you can use Tip 7: etags

to do this , but there is also another way: collapsing code. Both vim and emacs support this concept.
    • emacs**

In emacs, this feature is implemented in a "minor mode". To run it, type M-x outline-minor-mode. After this, you type M-x hide-other. In a C/C++ program, this will put ellipses between function braces { ... }. Your code is still there, but hidden. If you move to one of these functions, you can then type M-x show-subtree and the code will display again. There are ways to incrementally show more and more, but this shows either none or all. That is usually good enough.

    • vim**