vi editing  «Prev  Next»
Lesson 4 Creating text abbreviations
ObjectiveUse the :ab command to abbreviate text.

Creating text abbreviations (vi)

Because editing can be repetitive, you may find yourself typing common phrases over and over again.
For example, I sing in a quartet named Town Square Harmonizers, but it is inconvenient to constantly type our name in a file.
I can avoid repeatedly typing the name if I use the :ab command to save a sequence of text as an abbreviation, like this:
:ab tsh Town Square Harmonizers
From now on, whenever I am in text mode and I type the 'word' tsh, vi automatically expands it to Town Square Harmonizers. I say 'word' because abbreviations are not expanded until you type them as you would a regular word--with a space or punctuation mark after the abbreviation.
The table below shows the general form of the related abbreviation commands:

Command Description
:ab short long Define short as an abbreviation for long
:ab List your currently defined abbreviations
:unab short Turn off the definition for short

The following SlideShow shows some examples:
1) SQL abbreviated-commands 1 2) SQL abbreviated-commands 2 3) SQL abbreviated-commands 3 4) SQL abbreviated-commands 4 5) SQL abbreviated-commands 5 6) SQL abbreviated-commands 6
  1. In vi, begin the :ab command, which drops your cursor to the status line.
  2. After entering the :ab command, continue editing the file. In text mode, change the word.
  3. After typing tsh and then a space, the text abbreviation is triggered.
  4. Return to command made by pressing Escape. Then enter :w to save your changes.
  5. By using the :ab command without arguments, it lists your current abbreviations.
  6. If you quit vi, you lose any abbreviations that you defined during the session.

Program 1 Program 2 Program 3 Program 4 Program 5 Program 6
Click the link below to see a list of Text Abbreviations.
Text Abbreviations
In the next lesson, you will learn how to create keyboard macros with the :map command.