emacs键盘绑定在终端中不起作用 [英] emacs keybinding doesn't work in terminal

查看:112
本文介绍了emacs键盘绑定在终端中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.emacs文件中设置了以下键绑定:

I've set the following key bindings in my .emacs file:

(global-set-key (kbd "C-S-M-w") 'windmove-up)
(global-set-key (kbd "C-S-M-s") 'windmove-down)
(global-set-key (kbd "C-S-M-d") 'windmove-right)
(global-set-key (kbd "C-S-M-a") 'windmove-left)

(global-set-key (kbd "C-S-a") 'shrink-window-horizontally)
(global-set-key (kbd "C-S-d") 'enlarge-window-horizontally)
(global-set-key (kbd "C-S-s") 'shrink-window)
(global-set-key (kbd "C-S-w") 'enlarge-window)

当它们在自己的窗口中时,它们工作得很好.但是,如果我在终端(emacs -nw)中运行它,则不会加载键绑定.即使加载了.emacs文件,我仍然没有按键绑定.

They work just fine when they're in their own window. However, if I run it in terminal (emacs -nw) the keybindings aren't loaded. Even after loading the .emacs file I still don't have the keybindings.

当我使用emacs守护程序并在客户端vs终端中打开时,情况也是如此.如果重要的话,我在Linux机器上.

It's the same story when I use a emacs daemon and open in client vs in terminal. I'm on a linux machine if that matters.

推荐答案

emacs不存在问题,问题在于修饰符键(Control,Shift和Alt)的组合在大多数终端程序中的表现都非常差.类似的问题在这里以及在许多其他地方(包括超级用户)不断出现,例如: emacs-[控制上移]不起作用 https://superuser.com/q/230852 .您需要在特定的终端中对其进行测试-但是例如检查Gnome终端显示C-S-C-是无法区分的,因此大多数绑定甚至都无法正确地将其绑定到emacs

Problem is not with emacs, problem is combinations of modifier keys (Control, Shift and Alt) behave quite poorly in most terminal programs. Similar questions keep popping up here and in many other places, including superuser, for instance: emacs - [control shift up] doesn't work, and https://superuser.com/q/230852. You need to test it in your specific terminal - but checking Gnome terminal for instance shows that C-S- is indistinguishable from just C-, so most of your bindings aren't even making it to emacs properly

如果您需要说服自己,请使用C-h k,然后再丢失组合.您会看到,当您在终端中运行时,这些组合会被删除一些修饰符.

If you need to convince yourself use C-h k and then the combinations you are missing. You will see that when you run in a terminal those combinations are stripped of some modifiers.

我经历过类似的经历,得出的结论是,与航站楼作战是不值得的.我建议您在终端中时,将需要多个修饰符的组合键重新映射到其他组合. (例如,我最终将windmove命令重新映射为F键.)或者,我可以建议使用 evil领导者键(如果您使用邪恶的话),否则请上帝模式.这样就大大减少了对多个修饰符的需求.

I have been through similar experience and came to the conclusion that fighting with terminals isn't worth the effort. I suggest you remap the key combinations that need more than one modifier to something else, when you are in a terminal. (I ended up remapping windmove commands to F-keys, for instance.) Alternatively, I can recommend either using evil leader key (if you use evil), or God mode otherwise. That drastically reduces the need for multiple modifiers.

这篇关于emacs键盘绑定在终端中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆