Learn Vim at your own pace with my self-study Core Vim Course.

Learn more

Learn Vim at your own pace with my self-study Core Vim Course.

Enhanced abbreviations with :Abolish

#49

Run time:

Vim’s built-in abbreviation feature is handy if you want to auto-correct words that you frequently misspell, but it requires a lot of setup. The :Abolish command makes it easy to generate abbreviations that will correct multiple forms of the same word.

This is the final of a three-part series on Tim Pope’s abolish plugin.

Shownotes

Vim’s built-in abbreviations feature can provide auto-correct functionality. For example, we could make Vim auto-correct ‘colour’ (the British spelling) to ‘color’ (the American spelling) by running this command:

:iabbrev colour color

However, abbreviations are case sensitive, so if we wanted to trigger the auto-correction on ‘Colour’, we’d have to create another abbreviation. The same goes for ‘COLOUR’, as well as for ‘colours’, ‘coloured’, ‘colouring’, and so on.

The abolish plugin, by Tim Pope, provides a solution for this. It includes a smart command called :Abolish, which has a similar form to the built-in iabbrev command.

This single command:

:Abolish {hon,col}our{,s,ed,ing} {}or{}

Generates all of these abbreviations in one go:

:iabbrev  honours     honors
:iabbrev  honoured    honored
:iabbrev  HONOURS     HONORS
:iabbrev  Honoured    Honored
:iabbrev  HONOUR      HONOR
:iabbrev  honouring   honoring
:iabbrev  Honours     Honors
:iabbrev  honour      honor
:iabbrev  HONOURED    HONORED
:iabbrev  Honour      Honor
:iabbrev  HONOURING   HONORING
:iabbrev  Honouring   Honoring
:iabbrev  COLOURING   COLORING
:iabbrev  colouring   coloring
:iabbrev  COLOURED    COLORED
:iabbrev  Colouring   Coloring
:iabbrev  Coloured    Colored
:iabbrev  coloured    colored
:iabbrev  COLOURS     COLORS
:iabbrev  Colours     Colors
:iabbrev  colours     colors
:iabbrev  Colour      Color
:iabbrev  colour      color
:iabbrev  COLOUR      COLOR

The :Abolish command is really handy if you want to auto-correct the words that you frequently mis-spell. Check out Tim Pope’s abbreviations for ideas.

I’ve created an Americanize plugin, which uses the :Abolish command to auto-“correct” lots of British words to their American equivalents.

Further reading

Comments

Level-up your Vim

Training

Boost your productivity with a Vim training class. Join a public class, or book a private session for your team.

Drew hosted a private Vim session for the shopify team that was one of the best workshops I have ever attended.

John Duff, Director of Engineering at Shopify

Publications

Make yourself a faster and more efficient developer with the help of these publications, including Practical Vim (Pragmatic Bookshelf 2012), which has over 50 five-star reviews on Amazon.

After reading it, I've switched to vim as my default editor on a daily basis with no regrets. ★★★★★

Javier Collado

Learn to use Vim efficiently in your Ruby projects

In association with thoughtbot, one of the most well respected Rails consultancies in the world, I've produced a series of screencasts on how to make navigating your Ruby projects with Vim ultra-efficient. Along the way, you’ll also learn how to make Ruby blocks a first-class text object in Vim. This lets you edit Ruby code at a higher level of abstraction. Available to buy from thoughtbot..