42Chapter2 • Working With Editors
with a list of matching functions from which to choose. When you type in the appropriate num-
ber from the left-hand column, that function will be opened in the buffer.
2.4.4Folding Code
VIM can use several methods for folding code. The most useful of these for application
programming is the indent method. The variable
foldmethod
determines how the folding will
take place. To indent set the mode by typing:
:set foldmethod=indent
This command can also be set as a default by entering it in the ~/.vimrc configuration file.
When this option is set and a file is opened, VIM will parse the file looking for initial tab
sequences in order to determine the various indent levels and fold the file automatically. In order
to open or unfold a section, use
zo
and to close or refold a section, use
zc
.
The commands
zm
and
zr
can also be used to increase and decrease the amount of folding
currently being done to a file. By issuing the
zr
command, the amount of folding being done is
reduced by one
shiftwidth
level. That is to say, one level of tabbing is revealed in the code. The
zm
command reverses this and folds up one level of indentation every time that it is used.
2.5References and Resources
1.
Learning GNU Emacs, Second Edition, Debra Cameron, Bill Rosenblatt & Eric Ray-
mond, O’Reilly & Associates, Inc., ISBN:1-56592-152-6.
2.
GNU Emacs home page, http://www.gnu.org/software/emacs/emacs.html
3.
Jed home page, http://space.mit.edu/~davis/jed/
4.
GNU Emacs Lisp Reference Manual, http://www.gnu.org/manual/elisp-manual-21-2.8/
html_chapter/elisp.html
5.
Coffee.el, a fanciful elisp program to have Emacs make coffee, http://www.chez.com/
emarsden/downloads/coffee.el
6.
Xemacs home page. http://www.xemacs.org/
7.
VIM Home page. http://www.vim.org
Next Page >>
<< Previous Page
Back to the Table of Contents