Jump to content

How to Create Autotext with Vim's Abbreviations

+ 1
  carlaschroder's Photo
Posted Oct 16 2009 01:31 PM

If 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, use Vim's appreviations 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.

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).

Cover of Linux Cookbook
Learn more about this topic from Linux Cookbook. 

Linux information can be found scattered in man pages, texinfo files, and source code comments, but the best source is the experts who have built up a working knowledge of managing Linux systems. The Linux Cookbook's tested techniques distill years of hard-won experience into practical cut-and-paste solutions to everyday Linux dilemmas. Use just one recipe from this collection of real-world solutions, and the hours of tedious trial-and-error saved will more than pay for the cost of the book. It's more than a time-saver; it's a sanity saver.

Learn More Read Now on Safari


Tags:
0 Subscribe


0 Replies