ng some program source code into a file, and you have a long variable name, say OverallSalesTotal. Instead of typing that by hand every time, you can save yourself typing by setting up an abbreviation and telling your about it. In vi clones such as vim, for instance, you can do something like
:abb ost OverallSalesTotal
and from then on, whenever you type "ost" (followed by a space), the editor will automatically expand this to "OverallSalesTotal" for you. This not only saves time, but also again allows you to concentrate better on your programming, instead of being distracted.
Another way to do this is to use vim's word completion capability. Suppose I wish to type OverallSalesTotal as above, but I feel it would be too difficult to remember an abbreviation for each of the many variable and function names I have in my program. What I can do instead is use word completion:
I simply type enough of the word to make it unique. It may be, say, that this is OverallSalesTotal is the only word in my file which begins with "Ov". If so, I can type
where here ^n" means ctrl-n. This tells vim to complete "Ov" to the next word in the file which begins with "Ov", which will be OverallSalesTotal.
Of course, word completion is handy even when editing text files, say when composing e-mail. All of the editors mentioned at the outset of this document -- vim, emacs and jEdit -- have this feature. In emacs, for example, it is invoked as C-M / (this is emacs notation for first hitting and releasing the Ctrl key, then the Esc key, then /).
A common problem in editing program files is that we don't match parentheses or braces properly. Suppose for example in Lnk.c we had forgotten to put in the closing brace in the last else clause within Insert():
Upon running :make, we find:
Hmm...gcc thinks that at what we intended as the definition of ProcessData(), Insert()'s definition was not finished yet. So, let's move the cursor to the brace which will had intended to close Insert():
Now, let's use vim's % command to see which left brace this right brace matches:
Aha! The right brace pairs up with the opening brace of the while loop, not the opening brace of Insert(). In other words, there is a right brace missing somewhere in the loop. A little inspection reveals that it is the closing brace of the second else.
Many editors will display different items in a program source file according to a syntax color code. In the examples here, all types, e.g. int, have been displayed in green, all executable operations such as if in yellow, all variable names in black, and so on. We got this from vim by typing
It is a popular feature in many programmer-oriented editors.
After you become adept at using the various tricks in a given editor, say vim, why let all that go to waste in your other editing tasks, e.g. e-mail? It makes good sense to use the same editor for all your work.
Thus it would be nice to have whatever editor you use for programming work, say vim, as your default editor in your e-mail utility, say pine. That means that whenever your compose a new e-mail message or reply to one you receive, your e-mail utility will automatically invoke vim for your editing pleasure.
I personally use the mutt e-mail utility, and I strongly recommend it. But most of you use pine, so here is how to make vim your default editor in pine: When your first invoke pine, first choose S (Setup), then C (configure. Scroll through the choices there until you get to enable-alternate-editor-implicitly; there just type x and an X will appear in the box. (If you check the wrong box by mistake, just type x again to make it disapear.) Then continue to scroll though the choices until you come to "editor". At that point choose C (Change Val) and type vim. Then choose E (Exit Config) and answer y when asked whether to Commit. From this point on, vim will automatically pop up whenever you compose a new message or reply to an existing one. When you are done composing your message, simply exit vim with ZZ and then send the message as usual.