Set up a shortcut to insert a symbol

Despite living in the UK I am hard-wired from some years spent in the US to use a US keyboard layout. One problem for me is that these keyboards do not have a £ symbol on them. On a Mac, I can insert a £ using OPTION-3 but not in Emacs since I have OPTION set to META. This is easily addressed with a bit of code

(define-key global-map (kbd "C-c M-3") (lambda () (interactive) (insert "£")))

Now C-c M-3 will insert the £ symbol. N.B. I could have just bound this to M-3 to match the behaviour elsewhere on my Mac, but I already use that for something else!

  • Omar

    The default binding is `C-x 8 L`. There are lots of characters under the `C-x 8` prefix. I guess that L was chosen for the pound symbol because Emacs is so old some mnemonics are actually in Latin.

    • Thanks! I always forget about the goodies hiding behind `C-x 8`

  • Kaushal Modi

    Also it would be perfectly fine to replace the whole of (lambda () (interactive) (insert "£")) with "£".

  • Jonáš Šerých

    Not Emacs related, but I use compose key (set to my right alt) and I find it super nice. I was able to write £ (without ever doing it before or looking it up) just by typing `comp L -`. € is `comp = e` and so on. The combinations are very predicable -> you don’t have to remember anything. And it works outside Emacs as well (not that I would encourage anyone to go out there 🙂 ). See the table of combinations and maybe you will fall in love.