Emacs: Display Lambda as λ

By Xah Lee. Date: . Last updated: .
Alt+x prettify-symbols-mode
Display the word “lambda” as λ, in current buffer. (New in Emacs 24.4. [see Emacs 24.4 Features (released 2014-10)])
Alt+x global-prettify-symbols-mode
Globally. Put this in your Emacs Init File:
(global-prettify-symbols-mode 1)

Note, this only DISPLAYS any text “lambda” as λ, it doesn't actually change the text.

emacs pretty lambda 2021-09-25 g9TW
emacs pretty lambda 2021-09-25

Add Support for Pretty Symbols Mode

prettify-symbols-mode only works for major modes that supports it.

To add support, in your major mode, do:

(setq prettify-symbols-alist '(("lambda" . 955)))

The 955 is Unicode codepoint for λ in decimal. To find the Unicode codepoint of a char, type the char, then Alt+x describe-char. [see Emacs: Unicode Tutorial]

You can add other pairs. For example, to have arrow, do:

(setq prettify-symbols-alist
        ("lambda" . 955) ; λ
        ("->" . 8594)    ;         ("=>" . 8658)    ;         ("map" . 8614)    ;         ))

You can add it as a hook for any major mode. Here's a example:

(defun my-add-pretty-symbol ()
  "make some word display as Unicode symbols"
  (setq prettify-symbols-alist
          ("lambda" . 955) ; λ
          ("->" . 8594)    ;           ("=>" . 8658)    ;           ("map" . 8614)   ;           )))

(add-hook 'clojure-mode-hook 'my-add-pretty-symbol)
(add-hook 'haskell-mode-hook 'my-add-pretty-symbol)
(add-hook 'tex-mode-hook 'my-add-pretty-symbol)

[see Emacs: What is Hook]

For other math symbols you might want to add, see:

Unicode and Font

Emacs Init

Init Basics



Text Editing



Restore Things





Advanced Init Tips