Key Bindings in Emacs

Keystrokes are associated with commands via key bindings.

you can access those command don't have bindings by typing M-x command-name Enter.

key-map is a collection of key bindings.Global-mapis the most basic default key bindings in Emacs.Local-map is specific to a single buffer.Local key-maps are used to implement commands in modes

Emacs first looks it up in the current buffer's local-map (if any). If it doesn't find an entry there, it looks in global-map. If an entry for the key is found, its associated command is run.

键的绑定
You can create your own key bindings by adding entries in key-maps (or overriding existing ones). Three functions are available for doing this: define-key, global-set-key, and local-set-key. Their forms are:
(define-key keymap "keystroke" 'command-name)
(global-set-key "keystroke" 'command-name)    <=> (define-key global-map "keystroke" 'command-name)
(local-set-key "keystroke" 'command-name)
             <=> (define-key local-map "keystroke" 'command-name)


比如goto-line 命令用于跳转到某一行,当你进行调试的时候,会报出具体那一行出错,所以这个命令就是比较常用的。

(global-set-key "\C-xl" 'goto-line)
然后你可以通过C-x C-e 来执行光标所在的行,使他生效。

map的扩展

另外因为C-x / M- 这种等待后续输入的操作,同样具有自己的map,比如C-x 有Ctrl-x-map 所以下面的语法跟上面是等价的。

(define-key ctl-x-map "l" 'goto-line)

设置到特殊键

arrow,number keypad, Function keys. 分别为箭头,小键盘,F1系列功能键这个时候它不再是把keystrke放入双引号中,而是在一对方括号里面

 (global-set-key [f5] 'goto-line)      F5被赋予goto-line 
 (global-set-key [C-A-f5] 'goto-line)  Ctrl+alt+f5被赋予goto-line

取消键绑定

(global-unset-key [f5])
(define-key ctl-x-map "l" nil)


http://ergoemacs.org/emacs/keyboard_shortcuts.html
http://ergoemacs.org/emacs/keyboard_shortcuts.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值