0

I wanted to bind M-n to transpose-chars in evil insert state, and tried (define-key evil-insert-state-map "M-n" 'transpose-chars) But that didn't work. What should I do?

2
  • Try (define-key evil-insert-state-map (kbd "M-n") 'transpose-chars). Commented Aug 16, 2016 at 15:51
  • This has got to be a duplicate question. Hope someone will find the dup...
    – Drew
    Commented Aug 16, 2016 at 16:04

1 Answer 1

2

In (define-key KEYMAP KEY DEF) the KEY is internal representation of keys, where prefix keys must be \C- or \M-. A way to convert keys into internal representation is to use (kbd KEYS) function, where KEYS is string. In your question it could be two variants:

  • (define-key evil-insert-state-ma‌​p "\M-n" 'transpose-chars)
  • (define-key evil-insert-state-ma‌​p (kbd "M-n") 'transpose-chars)

https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Sequences.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.