Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rebind C-space in Emacs

I've tried various version to no avail:

(global-set-key (kbd "C-<space>") 'tempo-complete-tag)

(global-set-key [C-space] 'tempo-complete-tag)

I'm using CUA mode and running Emacs on Ubuntu, version: GNU Emacs 23.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.18.0) of 2009-09-27 on crested, modified by Debian

When I run tempo-complete-tag manually it tells me it is bound to C-space but C-space still runs cua-set-mark (or if CUA is disable, set-mark-command).

How can I rebind the C-space shortcut in Emacs to a command I decide?

like image 717
Adam Lindberg Avatar asked Jul 12 '10 08:07

Adam Lindberg


People also ask

How do I change Emacs shortcuts?

You can use global-set-key interactively by calling it with M-x global-set-key . Type the keyboard shortcut you would like to set, then specify the name of the function you would like Emacs to call.

What keys does Emacs use for special commands?

In the Emacs key binding notation, C-x is Ctrl+X; M-x is usually Alt+X; S-x is Shift+X; and C-M-x is Ctrl+Alt+X, etc. The help system is simple. Type C-h (or F1) and follow the di- rections. If you are a first-time user, type C-h t for a tutorial.


1 Answers

C-h k (key) will tell you how Emacs refers to a given key (which is "C-SPC" in this instance). (global-set-key (kbd "C-SPC") 'tempo-complete-tag) will do what you want.

I always use the (kbd) function for key-bindings, as it allows you to refer to the key the same way it is typically written everywhere else.

Do keep in mind that C-SPC is a standard set-mark-command binding! Personally I'd pick something different :)

like image 163
phils Avatar answered Sep 22 '22 00:09

phils