An abbrev expands whenever it is in a buffer just before point and you type a self-inserting punctuation character (SPC, comma, etc.). Most often an abbrev is used by inserting the abbrev followed by punctuation.
Abbrev expansion preserves case; thus, ‘foo’ expands into ‘find
outer otter’, ‘Foo’ into ‘Find outer otter’, and ‘FOO’ into
‘FIND OUTER OTTER’ or ‘Find Outer Otter’ according to the
abbrev-all-caps (a non-
nil value chooses the first
of the two expansions).
Two commands are available to control abbrev expansion:
Separate a prefix from a following abbrev to be expanded
Expand the abbrev before point (
This is effective even when Abbrev mode is not enabled.
Undo last abbrev expansion.
Expand some or all abbrevs found in the region.
You may wish to expand an abbrev with a prefix attached. For example,
if ‘cnst’ expands into ‘construction’, you may want to use it
to enter ‘reconstruction’. It does not work to type recnst,
because that is not necessarily a defined abbrev. Instead, you can use
the command M-' (
abbrev-prefix-mark) between the prefix
‘re’ and the abbrev ‘cnst’. First, insert ‘re’. Then
type M-'; this inserts a minus sign in the buffer to indicate that
it has done its work. Then insert the abbrev ‘cnst’. The buffer
now contains ‘re-cnst’. Now insert a punctuation character to
expand the abbrev ‘cnst’ into ‘construction’. The minus sign
is deleted at this point by M-'. The resulting text is the
If you actually want the text of the abbrev in the buffer, rather than its expansion, insert the following punctuation with C-q. Thus, foo C-q - leaves ‘foo-’ in the buffer.
If you expand an abbrev by mistake, you can undo the expansion (replace
the expansion by the original abbrev text) with M-x unexpand-abbrev.
You can also use C-_ (
undo) to undo the expansion; but that
will first undo the insertion of the punctuation character.
M-x expand-region-abbrevs searches through the region for defined abbrevs, and offers to replace each one it finds with its expansion. This command is useful if you have typed text using abbrevs but forgot to turn on Abbrev mode first. It may also be useful together with a special set of abbrev definitions for making several global replacements at once. The command is effective even if Abbrev mode is not enabled.