0

I want to create a new key binding that puts out a single letter with a key combination. For example: M-E inserts an "ê" character. Is this possible?

Dan
  • 32,584
  • 6
  • 98
  • 168
sblindo
  • 1
  • 1
  • Yes, bind a key to a command that uses `insert-char` to insert that character. – Drew Jun 13 '16 at 13:17
  • 1
    FYI, at least as tested on emacs 25 pretest version, `C-x 8 ^ e` inserts `ê`. Similarly using `A`, `E`, `I`, `O`, `U`, `a`, `i`, `o`, `u` after `C-x 8 ^` would work as you would guess. – Kaushal Modi Jun 13 '16 at 14:16
  • Have a look on this excellent reference on "mastering emacs": https://www.masteringemacs.org/article/mastering-key-bindings-emacs – turbopape Jun 13 '16 at 12:16
  • I try to insert this command inside my .emacs file: '**(global-set-key (kbd "M-x e") "ê")**' but there is an error... – sblindo Jun 13 '16 at 14:56
  • @sblindo `M-x` is already bound to a command so it can't be a prefix for a keybinding (as the error msg says). – JeanPierre Jun 13 '16 at 20:39

1 Answers1

1

Try this:

(global-set-key (kbd "M-e") '(lambda () (interactive) (insert-char 234)))

How to get 234? Place your cursor on the letter ê and press C-x =. Modeline will show you the codes:

Char: ê (234, #o352, #xea, file ...) point=3 of 27 (7%) column=0
Maxim Kim
  • 1,516
  • 9
  • 17