Search code examples
vimmacrosviabbreviation

When to use :abbr vs. :map in vi/vim


The abbreviation and map commands both appear to give the user redundant functionality. :imap teh the seems to get the same job done as :iabbr teh the. I tend to make all my settings in :map commands of various types- everything from typo fixes to script-like one-liners.

Is there a real difference between maps and abbreviations? Which command is best suited for which job?


Solution

  • The biggest difference in this specific case is that iabbr will only change the text once you've pressed space, and will show each character on the screen as you type. In contrast, imap will delay the display of all characters in teh until the map has resolved one way or the other. I'd recommend iabbr in this case - you'll see characters appear as you type, words that begin with the abbreviation will be handled correctly, and (most especially) you won't get an irritating delay for all words that start with t.