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)
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. [see Emacs: describe-char, Find a Char's Unicode Name, Codepoint, Encoding, Property, Font, Cursor Position]

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:

Font


Emacs Init

Init Basics

Keys

Font

Text Editing

Completion

File

Restore Things

Backup/AutoSave

Line

Appearance

Misc

Advanced Init Tips

packages