Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 758
user17925 Avatar asked Jan 01 '10 08:01

user17925


People also ask

How do you use abbreviations in vim?

Whenever you type the word 'teh', it will be replaced with 'the'. List all abbreviations. A flag is shown in the first column: 'i' means the abbreviation will be used in insert mode, 'c' for command-line mode, and '!' for both modes.

What is OMAP in vim?

*omap-info* Operator-pending mappings can be used to define a movement command that can be used with any operator.

How do I map a key in vi?

vi can assign sequences of commands to a series of keys or control characters so that whenever a mapped key sequence is typed, the command to which it is mapped is carried out. There are two commands to do this: :map, which works in command mode, and :map!, which works in insertion mode.

What is silent vim?

<silent> tells vim to show no message when this key sequence is used. <leader> means the key sequence starts with the character assigned to variable mapleader -- a backslash, if no let mapleader = statement has executed yet at the point nmap executes.


1 Answers

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.

like image 166
Peter Avatar answered Sep 28 '22 04:09

Peter