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?

  • Try (define-key evil-insert-state-map (kbd "M-n") 'transpose-chars). – Konstantin Morenko Aug 16 '16 at 15:51
  • This has got to be a duplicate question. Hope someone will find the dup... – Drew Aug 16 '16 at 16:04
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, privacy policy and cookie policy

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