Skip to main content

29.4 Examining and Editing Abbrevs

M-x list-abbrevs​

Display a list of all abbrev definitions. With a numeric argument, list only local abbrevs.

M-x edit-abbrevs​

Edit a list of abbrevs; you can add, alter or remove definitions.

The output from M-x list-abbrevs looks like this:

various other tables…
(lisp-mode-abbrev-table)
"dk" 0 "define-key"
(global-abbrev-table)
"dfn" 0 "definition"

(Some blank lines of no semantic significance, and some other abbrev tables, have been omitted.)

A line containing a name in parentheses is the header for abbrevs in a particular abbrev table; global-abbrev-table contains all the global abbrevs, and the other abbrev tables that are named after major modes contain the mode-specific abbrevs.

Within each abbrev table, each nonblank line defines one abbrev. The word at the beginning of the line is the abbrev. The number that follows is the number of times the abbrev has been expanded. Emacs keeps track of this to help you see which abbrevs you actually use, so that you can eliminate those that you don’t use often. The string at the end of the line is the expansion.

Some abbrevs are marked with ‘(sys)’. These system abbrevs (see Abbrevs in The Emacs Lisp Reference Manual) are pre-defined by various modes, and are not saved to your abbrev file. To disable a system abbrev, define an abbrev of the same name that expands to itself, and save it to your abbrev file.

M-x edit-abbrevs allows you to add, change or kill abbrev definitions by editing a list of them in an Emacs buffer. The list has the same format described above. The buffer of abbrevs is called *Abbrevs*, and is in Edit-Abbrevs mode. Type C-c C-c in this buffer to install the abbrev definitions as specified in the buffer—and delete any abbrev definitions not listed.

The command edit-abbrevs is actually the same as list-abbrevs except that it selects the buffer *Abbrevs* whereas list-abbrevs merely displays it in another window.