[英]How to switch to a different buffer from a terminal buffer
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). 我已经使用emacs几个星期了,它到目前为止一直很棒 - 来自
vim
比我想象的更容易(实际上 - emacs的键盘快捷键感觉更自然)。
I have added few customizations like moving between buffers using M-Left/Right/Up/Down
because Cx o
felt a little bit too slow when I had four files opened at once. 我添加了一些自定义项,例如使用
M-Left/Right/Up/Down
在缓冲区之间移动,因为当我一次打开四个文件时Cx o
感觉有点太慢了。
So far - so good :-) 到现在为止还挺好 :-)
One thing bugs me though: 但有一件事让我感到困惑:
Cx 3
and Cx 2
Cx 3
和Cx 2
打开一些分裂 Mx term ENT
Mx term ENT
打开其中一个终端 Usual shortcuts obviously don't work - terminal is intercepting every emacs command, and I have to click on different buffer to activate it. 通常的快捷方式显然不起作用 - 终端正在拦截每个emacs命令,我必须单击不同的缓冲区来激活它。
在术语模式中,任何常规Cx whatever
键绑定都会变成Cc whatever
而不是。
I'm not sure I understand your question. 我不确定我理解你的问题。 If you run Mx terminal , most of the key events are sent to the underlying terminal, so the standard Cx o binding and your M-Left are not available in the terminal.
如果您运行Mx终端 ,大多数关键事件将被发送到底层终端,因此标准Cx o绑定和您的M-Left在终端中不可用。
Try using Mx shell to get a shell in one of the windows, and the navigation bindings you set up should still work. 尝试使用Mx shell在其中一个窗口中获取shell,并且您设置的导航绑定应该仍然有效。
In term-mode, type Cc b RET
to switch to some other buffer. 在term-mode中,键入
Cc b RET
切换到其他缓冲区。
That does what Cx b RET normally does. 这就是Cx b RET通常做的事情。
This should do the trick to get Cx b working. 这应该可以让Cx b工作。 You may have to add bindings for any custom move commands.
您可能必须为任何自定义移动命令添加绑定。
(add-hook 'term-mode-hook
(lambda ()
;; C-x is the prefix command, rather than C-c
(term-set-escape-char ?\C-x)
(define-key term-raw-map "\M-y" 'yank-pop)
(define-key term-raw-map "\M-w" 'kill-ring-save)))
BTW, there is a big difference between shell-mode and term-mode. 顺便说一下,shell-mode和term-mode之间有很大的不同。 The former integrates better with emacs (eg cd command).
前者与emacs更好地集成(例如cd命令)。 The latter is a full terminal emulation and can handle curses programs.
后者是一个完整的终端仿真,可以处理curses程序。 They both have their place.
他们都有自己的位置。
For a more generic answer dealing with emacs' windows, you can look at windmove
, which started shipping with Emacs circa Emacs 22, I believe: 有关处理emacs窗口的更通用的答案,你可以看看
windmove
,它开始随Emacs Emacs 22开始发货,我相信:
;;; Commentary:
;;
;; This package defines a set of routines, windmove-{left,up,right,
;; down}, for selection of windows in a frame geometrically. For
;; example, `windmove-right' selects the window immediately to the
;; right of the currently-selected one. This functionality is similar
;; to the window-selection controls of the BRIEF editor of yore.
;;
;; One subtle point is what happens when the window to the right has
;; been split vertically; for example, consider a call to
;; `windmove-right' in this setup:
;;
;; -------------
;; | | A |
;; | | |
;; | |-----
;; | * | | (* is point in the currently
;; | | B | selected window)
;; | | |
;; -------------
;;
;; There are (at least) three reasonable things to do:
;; (1) Always move to the window to the right of the top edge of the
;; selected window; in this case, this policy selects A.
;; (2) Always move to the window to the right of the bottom edge of
;; the selected window; in this case, this policy selects B.
;; (3) Move to the window to the right of point in the selected
;; window. This may select either A or B, depending on the
;; position of point; in the illustrated example, it would select
;; B.
;;
;; Similar issues arise for all the movement functions. Windmove
;; resolves this problem by allowing the user to specify behavior
;; through a prefix argument. The cases are thus:
;; * if no argument is given to the movement functions, or the
;; argument given is zero, movement is relative to point;
;; * if a positive argument is given, movement is relative to the top
;; or left edge of the selected window, depending on whether the
;; movement is to be horizontal or vertical;
;; * if a negative argument is given, movement is relative to the
;; bottom or right edge of the selected window, depending on whether
;; the movement is to be horizontal or vertical.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.