Difference between revisions of "Tip 12: Collapsing Code"
Line 7: | Line 7: | ||
==vim== | ==vim== | ||
− | In vim, it is called "folding". Since I don't use emacs, you can find a tutorial on it | + | In vim, it is called "folding". Since I don't use emacs, you can find a tutorial on it [http://smartic.us/2009/04/06/code-folding-in-vim/ here]. |
− | + | ||
− | [http://smartic.us/2009/04/06/code-folding-in-vim/] | + |
Latest revision as of 16:36, 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
In vim, it is called "folding". Since I don't use emacs, you can find a tutorial on it here.