Vi 201 - Re-thinking Relativity (
Page 3 of 8 )
According to
Einstein, time is relative. According to Flootburger, time is money - especially
when you're billing by the hour. And so, for all you smarmy consultants-to-be,
here are some tips and tricks that should help you in bleeding the last cent
from your eight-hour day.
First on the list: abbreviations. Vi allows you
to define abbreviations for commonly-used words or phrases, and insert the
complete word or phrase simply by typing its abbreviation. All this happens via
the "abbreviate" command, which looks like this:
:abbreviate <abbreviation> <replacement-text>
or, for convenience,
:ab <abbreviation> <replacement-text>
From my own experience, I can tell you that this command is a
boon to all those of us blessed with a somewhat longer-than-usual name. In my
case, for example, I often use this abbreviation:
:abbreviate god Professor Elias Flootburger The Third
Go on - try it out yourself. Each time you type the word
"god" in your document and follow it with either a space or a carriage return,
vi will automatically replace it with the complete, unabridged
version.
And once you get tired of seeing my name all over your document
- how could you?! - you can remove the abbreviation with the
:unabbreviate god
or
:unab god
command.
To remove *all* abbreviations from memory,
the command to use is
:abclear
Abbreviations are particularly useful for inserting
frequently-used snippets of text - email addresses, telephone numbers and the
like - into your documents. As a standard rule of thumb, if you find yourself
typing the same piece of text more than five times in the same document, make it
an abbreviation and use the money you save on RSI treatments to buy yourself a
lifetime's worth of chocolate icecream - or simply donate it to the Flootburger
Foundation For The Empowerment Of Semi-Retired University Professors. All
donations are tax-deductible.
Vi also lets you enter symbols and accented
characters, which cannot normally be entered with a regular keyboard. A digraphs
table contains a list of different symbols, together with the key codes
necessary to enter them; all you need to do is locate your symbol in the table,
find the two characters that are mapped to create it, and enter them by typing
^-K <first-character> <second-character> [that's Ctrl-K]
For example, let's suppose you need to enter the copyright
symbol ©
The first thing you need to do is look up the digraphs table to
find out which combination of characters represents this symbol. You can access
the digraphs table with the
:digraphs
command.
As you'll see, the digraphs table consists of
a series of columns - the first two columns contain the characters which, when
combined, create the symbol in the third column. The fourth column contains the
decimal representation of the symbol. Our copyright symbol, for example, is
represented by the characters "A" and "~", and the decimal code 169.
Now,
in order to enter this symbol into your document, move to the appropriate
location and enter insert mode by typing
i
Next, type
^-K <first-character> <second-character> [that's Ctrl-K]
In this case,
^-K A ~ [that's Ctrl-K, followed by A ~]
and your symbol will be entered into the document.
Alternatively, if you'd prefer to use the decimal code, try
^-V <decimal code> [that's Ctrl-V]
In this case,
^-V 169 [that's Ctrl-V, followed by 169]
This article copyright 2000. All rights
reserved.