Vim Tips Wiki
(change "anon" author to blank; trim "created" date; minor manual clean)
(format + rough merge in from 992)
Line 6: Line 6:
 
|complexity=basic
 
|complexity=basic
 
|author=
 
|author=
|version=5.7
+
|version=6.0
 
|rating=17/14
 
|rating=17/14
 
|category1=Abbreviations
 
|category1=Abbreviations
Line 16: Line 16:
   
 
Examples:
 
Examples:
; <nowiki>:</nowiki>ab rtfm read the fine manual
+
;<tt>:ab rtfm read the fine manual</tt>
: Whenever you type 'rtfm' followed by punctuation such as a space or comma, the 'rtfm' will be expanded to 'read the fine manual'. This also happens if you type 'rtfm' then press Esc or Enter.
+
:Whenever you type 'rtfm' followed by punctuation such as a space or comma, the 'rtfm' will be expanded to 'read the fine manual'. This also happens if you type 'rtfm' then press Esc or Enter.
   
; <nowiki>:</nowiki>ab teh the
+
;<tt>:ab teh the</tt>
: Whenever you type the word 'teh', it will be replaced with 'the'.
+
:Whenever you type the word 'teh', it will be replaced with 'the'.
   
; <nowiki>:</nowiki>ab
+
;<tt>:ab</tt>
: 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.
+
: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.
   
  +
;<tt>:una rtfm</tt>
; <nowiki>:</nowiki>una rtfm
 
: unabbreviate &mdash; remove 'rtfm' from the list of abbreviations.
+
:unabbreviate remove 'rtfm' from the list of abbreviations.
   
; <nowiki>:</nowiki>abc
+
;<tt>:abc</tt>
: abclear &mdash; remove all abbreviations.
+
:abclear remove all abbreviations.
   
 
'''Note''': To avoid expansion in insert mode, type Ctrl-V after the last character of the abbreviation (on Windows, type Ctrl-Q instead of Ctrl-V).
 
'''Note''': To avoid expansion in insert mode, type Ctrl-V after the last character of the abbreviation (on Windows, type Ctrl-Q instead of Ctrl-V).
  +
  +
==Rough merge in from 992 (now removed)==
  +
The 'helpgrep' command is very useful for searching through all the files located in the .vim/doc directory. This command is especially useful if your .vim/doc directory is littered with script documentation as well as language specific documentation such as provided by {{script|id=614}}, {{script|id=826}} or {{script|id=1330}}.
  +
  +
The following abbreviation provides faster access to 'helpgrep'.
  +
<pre>
  +
:cnoreabbrev H helpgrep
  +
</pre>
  +
  +
This allows me to type <tt>:H uganda</tt> to search for the word 'uganda' in all of the help files.
   
 
==References==
 
==References==

Revision as of 03:30, 24 March 2010

Tip 43 Printable Monobook Previous Next

created 2001 · complexity basic · version 6.0


Use the :abbreviate command to define abbreviations.

Abbreviations can save typing, and can improve accuracy, when you need to enter the same text throughout your document. You can also create abbreviations to automatically correct common typing errors (such as changing teh to the).

Examples:

:ab rtfm read the fine manual
Whenever you type 'rtfm' followed by punctuation such as a space or comma, the 'rtfm' will be expanded to 'read the fine manual'. This also happens if you type 'rtfm' then press Esc or Enter.
:ab teh the
Whenever you type the word 'teh', it will be replaced with 'the'.
:ab
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.
:una rtfm
unabbreviate – remove 'rtfm' from the list of abbreviations.
:abc
abclear – remove all abbreviations.

Note: To avoid expansion in insert mode, type Ctrl-V after the last character of the abbreviation (on Windows, type Ctrl-Q instead of Ctrl-V).

Rough merge in from 992 (now removed)

The 'helpgrep' command is very useful for searching through all the files located in the .vim/doc directory. This command is especially useful if your .vim/doc directory is littered with script documentation as well as language specific documentation such as provided by script#614, script#826 or script#1330.

The following abbreviation provides faster access to 'helpgrep'.

:cnoreabbrev H helpgrep

This allows me to type :H uganda to search for the word 'uganda' in all of the help files.

References

Comments