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?
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.
*omap-info* Operator-pending mappings can be used to define a movement command that can be used with any operator.
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.
<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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With