Can Emacs differentiate between ctrl-r and ctrl-shift-r?

雨燕双飞 提交于 2019-12-30 05:37:20

问题


I'd like to bind Ctrl + R to 'isearch-backward and bind Ctrl + Shift + R to 'tags-apropos but I can't distinguish between the two key presses.

Can emacs differentiate between Ctrl + R and Ctrl + Shift + R? What should go into my .emacs file to allow this keybinding?


回答1:


Yes.

(global-set-key (kbd "C-r") 'isearch-backward)
(global-set-key (kbd "C-S-r") 'tags-apropos)

The way to figure out the answer to this kind of question is to do help on a key C-h k, and type the keystrokes you're interested in. What Emacs shows in the Help buffer is the string you can pass to the macro 'kbd.




回答2:


Yes -- one is "\C-r", the other is "\C-R". They can easily be bound to separate commands. For example, this should do the trick if placed in your .emacs file:

(global-set-key "\C-R" 'tags-apropos)


来源:https://stackoverflow.com/questions/858713/can-emacs-differentiate-between-ctrl-r-and-ctrl-shift-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!