如何从终端缓冲区切换到不同的缓冲区
我已经使用 emacs 几个星期了,到目前为止它非常棒 - 来自 vim
比我预期的更容易(实际上 - emacs 的键盘快捷键感觉更......自然)。
我添加了一些自定义设置,例如使用 M-Left/Right/Up/Down
在缓冲区之间移动,因为当我同时打开四个文件时,Cx o
感觉有点太慢。
到目前为止 - 很好:-)
不过有一件事让我烦恼:
- 我使用
Cx 3
和Cx 2
打开一些拆分, - 我使用
在其中一个拆分中打开终端Mx term ENT
- 如何使用键盘切换到不同的分割?
通常的快捷方式显然不起作用 - 终端正在拦截每个 emacs 命令,我必须单击不同的缓冲区才能激活它。
I've been using emacs for few weeks and it's been great so far - coming from vim
was easier than I expected (actually - emacs' keyboard shortcuts feel more... natural).
I have added few customizations like moving between buffers using M-Left/Right/Up/Down
because C-x o
felt a little bit too slow when I had four files opened at once.
So far - so good :-)
One thing bugs me though:
- I open some splits using
C-x 3
andC-x 2
- I open the terminal in one of them using
M-x term ENT
- How do I switch to different split using keyboard?
Usual shortcuts obviously don't work - terminal is intercepting every emacs command, and I have to click on different buffer to activate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在术语模式下,任何常规的
Cxwhatever
键绑定都会变成Ccwhatever
。In term-mode, any regular
C-x whatever
keybinding becomesC-c whatever
instead.我不确定我是否理解你的问题。如果您运行 Mx 终端,大多数关键事件都会发送到底层终端,因此标准 Cx o 绑定和您的 M-Left在终端中不可用。
尝试使用 Mx shell 在其中一个窗口中获取 shell,您设置的导航绑定应该仍然有效。
I'm not sure I understand your question. If you run M-x terminal, most of the key events are sent to the underlying terminal, so the standard C-x o binding and your M-Left are not available in the terminal.
Try using M-x shell to get a shell in one of the windows, and the navigation bindings you set up should still work.
在 term-mode 中,输入
Cc b RET
切换到其他缓冲区。这与 Cx b RET 通常的作用相同。
In term-mode, type
C-c b RET
to switch to some other buffer.That does what C-x b RET normally does.
这应该可以让 Cx b 正常工作。您可能必须为任何自定义移动命令添加绑定。
顺便说一句,shell 模式和 term 模式之间有很大的区别。前者与 emacs 集成得更好(例如 cd 命令)。后者是一个完整的终端仿真,可以处理curses程序。他们都有自己的位置。
This should do the trick to get C-x b working. You may have to add bindings for any custom move commands.
BTW, there is a big difference between shell-mode and term-mode. The former integrates better with emacs (e.g. cd command). The latter is a full terminal emulation and can handle curses programs. They both have their place.
对于处理 emacs 窗口的更通用的答案,您可以查看
windmove
,它在 Emacs 22 左右开始随 Emacs 一起发布,我相信:For a more generic answer dealing with emacs' windows, you can look at
windmove
, which started shipping with Emacs circa Emacs 22, I believe: