Think Pl
Think Pl

Reputation: 131

How do I map M-x to "`" key in emacs 24 (Mac OS X Lion)

I've downloaded Emacs 24 pretest for Mac OS X and using Prelude + evil kit. I am coming from vim background and find that M-x is too slow and painful to use. Is there any way to map M-x key to ` key that is near the ESC key? Thanks.

Upvotes: 3

Views: 2773

Answers (2)

TacticalCoder
TacticalCoder

Reputation: 6325

find that M-x is too slow and painful to use

I'm a touch-typist and I happen to think the same and I also think that, in addition, all the C-x shortcuts are very hard to do too.

Is there any way to map M-x key to ` key that is near the ESC key?

I would say that the ESC key is not really a "close" key: your left pinky has to travel a lot to get there (you either need to move your entire hand, which is not efficient, or you need to "stretch" your fingers).

What I did, on a QWERTY keyboard, is to remap C-X to C-,

You may want to do something similar: in my opinion it really helps. So maybe mapping C-x to C-, and M-x to M-, would help?

You can do this like the other answer suggested by directly setting a global key:

(define-key global-map [(control ,)] ctl-x-map)

or you can define your own minor-mode where you put all your mappings and then turn that minor mode on (I learned that here on SO):

(define-key my-keys-minor-mode-map (kbd "C-,") ctl-x-map)
(define-key my-keys-minor-mode-map (kbd "M-,") 'execute-extended-command)
... put more mappings here ...

(define-minor-mode my-keys-minor-mode
  "A minor mode so that my key settings override annoying major modes."
  t " my-keys" 'my-keys-minor-mode-map)

(my-keys-minor-mode 1)

Or course you "lose" the previous mappings to C-, and M-, but IMHO it's totally worth it.

You probably want to read user scottfrazer's great answer and explanation here (that's what I followed to create my own key minor-mode in my .emacs file):

Globally override key binding in Emacs

Upvotes: 3

Burton Samograd
Burton Samograd

Reputation: 3638

(global-set-key (kbd "`") 'execute-extended-command)

Upvotes: 4

Related Questions