sponsor Vim development Vim logo Vim Book Ad

basic Tip #43: Using abbreviations

 tip karma   Rating 9/9, Viewed by 1044 

created:   March 9, 2001 4:27      complexity:   basic
author:   Anonymous      as of Vim:   5.7

To define abbreviations, use the ab[breviate] command.

Examples:

:ab rtfm read the fine manual  -  Whenever you type 'rtfm' followed by a <space> (or <esc> or <cr>) vim
                                  will expand this to 'read the fine manual'.

:ab                            -  list all defined abbreviations

:una[bbreviate] rtfm           -  remove 'rtfm' from the list of abbreviations

:abc[lear]                     -  remove all abbreviations


NB: To avoid expansion in insert mode, type CTRL-V after the last character of the abbreviation.

For a detailed description of the ab[breviate] command and some more examples refer to

:help abbreviations

 rate this tip  Life Changing Helpful Unfulfilling 

<<Using marks | Repeat last changes >>

Additional Notes

[email protected], March 13, 2001 8:22
Abbreviations can also be used to correct spelling, for example:

ab teh the
[email protected], January 4, 2002 15:45
I don't know why you would, but this is interesting.

If you have abbreviations set up like this:
!   g1   hello
!   g2   howdy
!   g3   hello
!   g4   greetings

and you do a :una g3 it will expand g3 to hello and delete both g1 and g3.  

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo