3

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.

Think Pl
  • 131
  • 1
  • 2

2 Answers2

4
(global-set-key (kbd "`") 'execute-extended-command)
Burton Samograd
  • 3,652
  • 19
  • 21
3

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

Community
  • 1
  • 1
TacticalCoder
  • 6,275
  • 3
  • 31
  • 39
  • Emacs Version 24.3 (9.0) -- Symbol's value as variable is void: my-keys-minor-mode-map – lawlist Apr 14 '13 at 16:36
  • @lawlist: yes, it's normal, I just gave an overview here. In the answer I linked to user *scottfrazer* explains how to *defvar* that minor mode keymap : ) Hope it helps. – TacticalCoder Apr 14 '13 at 16:40
  • Thank you -- I just bookmarked the link and will include a few examples in my Preferences.el -- greatly appreciated. – lawlist Apr 14 '13 at 20:36
  • @lawlist: the advantage of that method that *scottfrazer* gave is that it's quite clean: you can simply decide not to use that keymap mode and then Emacs is back to the normal/default shortcuts : ) When I read about it I modified my *.emacs* immediately, it's really convenient! – TacticalCoder Apr 15 '13 at 21:14