(emacs)Expanding Abbrevs

Next: Editing Abbrevs Prev: Defining Abbrevs Up: Abbrevs

Controlling Abbrev Expansion

   An abbrev expands whenever it is present in the buffer just before
point and a self-inserting punctuation character (SPC, comma, etc.) is
typed.  Most often the way an abbrev is used is to insert 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 variable
`abbrev-all-caps' (a non-`nil' value chooses the first of the two

   These two commands are used to control abbrev expansion:

     Separate a prefix from a following abbrev to be expanded

`C-x a e'
     Expand the abbrev before point (`expand-abbrev').  This is
     effective even when Abbrev mode is not enabled.

`M-x unexpand-abbrev'
     Undo last abbrev expansion.

`M-x expand-region-abbrevs'
     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 might want to use
it to enter `reconstruction'.  It does not work to type `recnst',
because that is not necessarily a defined abbrev.  What does work is to
use the command `M-'' (`abbrev-prefix-mark') in 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,
because `M-'' left word for this to be done.  The resulting text is the
desired `reconstruction'.

   If you actually want the text of the abbrev in the buffer, rather
than its expansion, you can accomplish this by inserting 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'.  `C-_' (`undo') can also be used to undo the
expansion; but first it undoes the insertion of the following
punctuation character.  Therefore, if you want both the punctuation
character and the unexpanded abbrev, you must reinsert the punctuation
character, quoting it with `C-q'.

   `M-x expand-region-abbrevs' searches through the region for defined
abbrevs, and for each one found offers to replace it with its expansion.
This command is useful if you have typed in 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.  This command is effective even if Abbrev mode is
not enabled.

   Expanding an abbrev runs the hook `pre-abbrev-expand-hook' (*note

automatically generated by info2www