3.22 Abbreviations
Abbreviations (abbrevs) can be defined by the user, such that if an abbreviation is typed at the keyboard followed by a word terminating character (such as Space or,), the expansion is found and used to replace the abbreviation. Typing can thereby be saved for frequently used words or sequences of characters.
There are two kinds of abbreviations: global abbreviations, which are expanded in all major modes; and mode abbreviations, which are expanded only in defined major modes.
Abbreviations (both global and mode) are only expanded automatically when Abbrev mode (a minor mode) is on. The default is for abbrev mode to be off.
All abbreviations that are defined can be saved in a file and reloaded during later editor sessions.
Abbrev ModeEditor Command
- Arguments: None
Key sequence: None - Switches abbrev mode on if it is currently off, and off if it is currently on. Only when in abbrev mode are abbreviations automatically expanded.
Add Mode Word AbbrevEditor Command
- Arguments: abbrev
Key sequence:Ctrl+X Ctrl+Aabbrev - Defines a mode abbreviation for the word before the current point.
- A positive prefix argument defines an abbreviation for the appropriate number of words before the current point. A zero prefix argument defines an abbreviation for all the text in the region between the mark and the current point. A negative prefix argument deletes an abbreviation.
Inverse Add Mode Word AbbrevEditor Command
- Arguments: expansion
Key sequence:Ctrl+X Ctrl+Hexpansion - Defines the word before the current point as a mode abbreviation for expansion.
Add Global Word AbbrevEditor Command
- Arguments: abbrev
Key sequence:Ctrl+X +abbrev - Defines a global abbreviation for the word before the current point.
- A positive prefix argument defines an abbreviation for the appropriate number of words before the current point. A zero prefix argument defines an abbreviation for all the text in the region between the mark and the current point. A negative prefix argument deletes an abbreviation.
Inverse Add Global Word AbbrevEditor Command
- Arguments: expansion
Key sequence:Ctrl+X -expansion - Defines the word before the current point as a global abbreviation for expansion.
Make Word AbbrevEditor Command
- Arguments: abbrev expansion mode
Key sequence: None
editor:make-word-abbrev-command p &optional abbrev expansion mode
- Defines an abbreviation for expansion without reference to the current point. The default value for mode is global.
Abbrev Expand OnlyEditor Command
- Arguments: None
Key sequence: None - Expands the word before the current point into its abbreviation definition (if it has one). If the buffer is currently in abbrev mode then this is done automatically on meeting a word defining an abbreviation.
Word Abbrev Prefix PointEditor Command
- Arguments: None
Key sequence: +' - Allows the prefix before the current point to be attached to the following abbreviation. For example, if the abbreviation
valn is bound tovaluation, typingre followed by +', followed byvaln, results in the expansionrevaluation.
Unexpand Last WordEditor Command
- Arguments: None
Key sequence: None - Undoes the last abbreviation expansion. If this command is typed twice in succession, the previous abbreviation is restored.
Delete Mode Word AbbrevEditor Command
- Arguments: abbrev
Key sequence: None
editor:delete-mode-word-abbrev-command p &optional abbrev mode
- Deletes a mode abbreviation for the current mode. A prefix argument causes all abbreviations defined in the current mode to be deleted.
- The argument mode is the name of the mode for which the deletion is to be applied. The default is the current mode.
Delete Global Word AbbrevEditor Command
- Arguments: abbrev
Key sequence: None
editor:delete-global-word-abbrev-command p &optional abbrev
- Deletes a global abbreviation. A prefix argument causes all global abbreviations currently defined to be deleted.
Delete All Word AbbrevsEditor Command
- Arguments: None
Key sequence: None - Deletes all currently defined abbreviations, both global and mode.
List Word AbbrevsEditor Command
- Arguments: None
Key sequence: None - Displays a list of all the currently defined abbreviations in an Abbrev window.
Word Abbrev AproposEditor Command
- Arguments: search-string
Key sequence: None
editor:word-abbrev-apropos-command p &optional search-string
- Displays a list of all the currently defined abbreviations which contain search-string in their abbreviation definition or mode. The list is displayed in an Abbrev window.
Edit Word AbbrevsEditor Command
- Arguments: None
Key sequence: None - Allows recursive editing of currently defined abbreviations. The abbreviation definitions are displayed in an Edit Word Abbrevs buffer, from where they can be can be added to, modified, or removed. This buffer can then either be saved to an abbreviations file, or
Define Word Abbrevs can be used to define any added or modified abbreviations in the buffer. When editing is complete,Exit Recursive Edit should be invoked.
Write Word Abbrev File Editor Command
- Arguments: filename
Key sequence: None
editor:write-word-abbrev-file-command p &optional filename
- Saves the currently defined abbreviations to filename. If no file name is provided, the default file name defined by the editor variable
Abbrev-Pathname-Defaults is used.
Append to Word Abbrev File Editor Command
- Arguments: filename
Key sequence: None
editor:append-to-word-abbrev-file-command p &optional filename
- Appends all abbreviations that have been defined or redefined since the last save to filename. If no file name is provided, the default file name defined by the editor variable
Abbrev-Pathname-Defaults is used.
Abbrev-Pathname-DefaultsEditor Variable
- Default value:
abbrev.defns - Defines the default file name for saving the abbreviations that have been defined in the current buffer.
Read Word Abbrev FileEditor Command
- Arguments: filename
Key sequence: None
editor:read-word-abbrev-file-command p &optional filename
- Reads previously defined abbreviations from filename. The format of each abbreviation must be that used by
Write Word Abbrev File andInsert Word Abbrevs.
Insert Word AbbrevsEditor Command
- Arguments: None
Key sequence: None - Inserts into the current buffer, at the current point, a list of all currently defined abbreviations. This is similar to
Write Word Abbrev File,except that the abbreviations are written into the current buffer rather than a file.
Define Word AbbrevsEditor Command
- Arguments: None
Key sequence: None - Defines abbreviations from the definition list in the current buffer. The format of each abbreviation must be that used by
Write Word Abbrev File andInsert Word Abbrevs.