Use abbrev to Enter Special Characters

As it’s described in the GNU Emacs Manual, an abbreviation or abbrev is a string of characters that may be expanded to a longer string. The user can insert the abbrev string and find it replaced automatically with the expansion of the abbrev. This saves typing.

Mostly I use builtin abbrev package to enter the special characters like greek letters, arrow symbols etc.

Below is my setup of abbrev from my ~/.emacs.

(setq abbrev-file-name                ;; Tell Emacs where to read abbrev
      "~/.emacs.d/abbrev_defs.el")    ;; Definitions from...
(setq save-abbrevs t)                 ;; (ask) save abbrevs when files are saved
(setq-default abbrev-mode t)          ;; Turn it on globally
(if (file-exists-p abbrev-file-name) (quietly-read-abbrev-file))

Here is my abbrev definition file ~/.emacs.d/abbrev_defs.el.

;; Time-stamp: <Last changed 2022-08-16 16:38:50 by magnolia>

(define-abbrev-table 'global-abbrev-table
  '(
    ("8alpha"   "α")
    ("8beta"    "β")
    ("8gamma"   "γ")
    ("8Delta"   "Δ")
    ("8delta"   "δ")
    ("8theta"   "θ")
    ("8ksi"     "ξ")
    ("8lambda"  "λ")
    ("8mu"      "µ")
    ("8nu"      "ν")
    ("8pi"      "π")
    ("8Sigma"   "Σ")
    ("8sigma"   "σ")
    ("8tau"     "τ")
    ("8phi"     "φ")
    ("8psi"     "ψ")
    ("8Omega"   "Ω")
    ("8omega"   "ω")
    ("8in"      "∈")
    ("8nin"     "∉")
    ("8almost"  "≈")
    ("8inf"     "∞")
    ("8deg"     "°")
    ("8cels"    "℃")
    ("8right"   "→")
    ("8left"    "←")
    ("8up"      "↑")
    ("8down"    "↓")
    ("8para"    "§")
    ("8copy"    "©")
    ("8reg"     "®")
    ("8tm"      "™")
    ("8eur"     "€")
    ("8pound"   "£")
    ("8plusmin" "±")
    ("8sup1"    "¹")
    ("8sup2"    "²")
    ("8sup3"    "³")
    ("8ldquo"   "«")
    ("8rdquo"   "»")
    ("8range"   "÷")
    ("8not"     "¬")
    ("8mdot"    "·")
    ("8bull"    "∙")
    ("8accent"  "´")
    ("8mdash"   "—")
    ("8ndash"   "–")))

Just after you type an abbreviation following by either SPC or any punctuation symbol it is replaced by the corresponding character.

Of course, I’ve compiled this setup from various sources, mostly from the Impaktor’s article with some additions.

It’s also worth to read the Xah Lee’s article for more examples of how to use abbrev mode in your daily Emacs life.

Happy abbreving.