如何从终端缓冲区切换到不同的缓冲区

时间:2010-01-31 21:12:45

标签: emacs emacs23

我已经使用emacs几个星期了,到目前为止它很棒 - 来自vim比我想象的要容易(实际上 - emacs的键盘快捷键感觉更自然)。

我添加了一些自定义项,例如使用M-Left/Right/Up/Down在缓冲区之间移动,因为当我一次打开四个文件时C-x o感觉有点太慢了。

到目前为止 - 非常好: - )

但有一件事让我感到困惑:

  1. 我使用C-x 3C-x 2
  2. 打开了一些拆分
  3. 我使用M-x term ENT
  4. 打开其中一个终端
  5. 如何使用键盘切换到不同的分割?
  6. 通常的快捷方式显然不起作用 - 终端正在拦截每个emacs命令,我必须点击不同的缓冲区来激活它。

5 个答案:

答案 0 :(得分:120)

在学期模式下,任何常规C-x whatever键绑定都会变为C-c whatever

答案 1 :(得分:10)

我不确定我理解你的问题。如果你运行 Mx terminal ,大多数关键事件都被发送到底层终端,所以标准的 Cx o 绑定和你的 M-Left 在终端没有。

尝试使用 M-x shell 在其中一个窗口中获取shell,并且您设置的导航绑定仍应有效。

答案 2 :(得分:8)

在术语模式下,键入C-c b RET以切换到其他缓冲区。

这就是C-x b RET通常所做的事情。

答案 3 :(得分:3)

这应该可以让C-x b正常工作。您可能必须为任何自定义移动命令添加绑定。

(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)))
顺便说一下,shell-mode和term-mode之间有很大的不同。前者与emacs(例如cd命令)更好地集成。后者是一个完整的终端仿真,可以处理curses程序。他们都有自己的位置。

答案 4 :(得分:2)

有关处理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.