Rebind C-space in Emacs

混江龙づ霸主 提交于 2019-12-04 04:42:44

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 :)

Also keep in mind that "global-set-key" will only do what you want, if your mode doesn't override it. I'm too lazy to load tempo to see if it does indeed override C-SPC, but it might well do so, in which case, you want to put this in your .emacs:

(add-hook 'tempo-mode-hook
          (lambda ()
            (local-set-key (kbd "C-SPC") 'tempo-complete-tag)
            ))

Alternative syntax for key binding is via vector:

(global-set-key [?\M-\ ] 'cycle-spacing)
(global-set-key [?\C-\ ] 'tempo-complete-tag)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!