Search code examples
macosemacsmacportskeymappingkeymaps

Emacs: how to bind action to mac Option (⌥) + arrow key combinations?


I'm using Emacs on OS X from mac ports. By default I have Ctrl as Control key, and Command as Meta key. Thogh, this is quite handy, I'm missing possibility to move cursor one word backward/forward by pressing M-arrrow key, i.e. + to move one word forward. What I realy want to have:

  • + move 1 word backward
  • + move 1 word forward
  • + move to 1st non-whitespace charachter of the line
  • + move to the line end
  • while in all other cases Meta

I tryed to use in my mappings (kbd "A-left"), "\A-left", but this does not worked for me. So, two questions here:

UPDATED

  1. how to create mapping for Option key?
(setq mac-option-modifier 'hyper)
;; now you can easily use mappings with Hyper key modifier
  1. how to cerate mapping to arrow keys?
(define-key evil-insert-state-map (kbd "<H-left>") 'left-word)
;; defines Hyper+left arrow combination

Solution

  • I do not have a mac. Could you try following the instructions at the bottom of the page http://ergoemacs.org/emacs/emacs_hyper_super_keys.html

    You can use C-h c to describe a keybinding by typing it which also returns the string that you have to give as a parameter to kbd.