[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

34.2 Defining Abbrevs

C-x a g

Define an abbrev, using one or more words before point as its expansion (add-global-abbrev).

C-x a l

Similar, but define an abbrev specific to the current major mode (add-mode-abbrev).

C-x a i g

Define a word in the buffer as an abbrev (inverse-add-global-abbrev).

C-x a i l

Define a word in the buffer as a mode-specific abbrev (inverse-add-mode-abbrev).

M-x define-global-abbrev <RET> abbrev <RET> exp <RET>

Define abbrev as an abbrev expanding into exp.

M-x define-mode-abbrev <RET> abbrev <RET> exp <RET>

Define abbrev as a mode-specific abbrev expanding into exp.

M-x kill-all-abbrevs

Discard all abbrev definitions, leaving a blank slate.

The usual way to define an abbrev is to enter the text you want the abbrev to expand to, position point after it, and type C-x a g (add-global-abbrev). This reads the abbrev itself using the minibuffer, and then defines it as an abbrev for one or more words before point. Use a numeric argument to say how many words before point should be taken as the expansion. For example, to define the abbrev ‘foo’ as mentioned above, insert the text ‘find outer otter’ and then type C-u 3 C-x a g f o o <RET>.

An argument of zero to C-x a g means to use the contents of the region as the expansion of the abbrev being defined.

The command C-x a l (add-mode-abbrev) is similar, but defines a mode-specific abbrev. Mode-specific abbrevs are active only in a particular major mode. C-x a l defines an abbrev for the major mode in effect at the time C-x a l is typed. The arguments work the same as for C-x a g.

If the abbrev text itself is already in the buffer, you can use the commands C-x a i g (inverse-add-global-abbrev) and C-x a i l (inverse-add-mode-abbrev) to define it as an abbrev by specify the expansion in the minibuffer. These commands are called “inverse” because they invert the meaning of the two text strings they use (one from the buffer and one read with the minibuffer).

You can define an abbrev without inserting either the abbrev or its expansion in the buffer using the command define-global-abbrev. It reads two arguments—the abbrev, and its expansion. The command define-mode-abbrev does likewise for a mode-specific abbrev.

To change the definition of an abbrev, just define a new definition. When the abbrev has a prior definition, the abbrev definition commands ask for confirmation before replacing it.

To remove an abbrev definition, give a negative argument to the abbrev definition command: C-u - C-x a g or C-u - C-x a l. The former removes a global definition, while the latter removes a mode-specific definition. M-x kill-all-abbrevs removes all abbrev definitions, both global and local.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 23 Février 2009 en utilisant texi2html 1.78.