Recipe 6.10. Creating Autotext with Vim's Abbreviations
6.10.1 Problem
You do a lot
of repetitious typing, such as copyright statements, code comments,
signatures, and so forth, and you would like some kind of auto-text
feature.
6.10.2 Solution
Use Vim's abbreviations feature. Abbreviations are
created in Normal mode:
:ab th This is an example of a Vim abbreviation.
To use the abbreviation, switch to Insert mode and type
th, followed by any whitespace above (space,
tab, or carriage return).
To see all of your abbreviations, type:
:ab
To remove an abbreviation, use:
:unabbreviate th
To delete all abbreviations, use:
:abclear
Like everything else in Vim, abbreviations can be preserved forever
in ~/.vimrc.
6.10.3 Discussion
You can use the abbreviation as an automatic spelling-fixer (like
Recipe 6.6). Just define your common misspellings as abbrevations.
This trick works best for typos (teh for the, for instance).
6.10.4 See Also
Vim's online help (:help
map.txt) Recipe 6.12 Chapter 24 of Vi IMproved—Vim Chapter 7 of Learning the vi Editor
|