67

我已经使用 emacs 几个星期了,到目前为止一切都很好 - 来自vim比我预期的更容易(实际上 - emacs 的键盘快捷键感觉更......自然)。

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

到现在为止还挺好 :-)

不过有一件事让我很烦恼:

  1. C-x 3我使用和打开一些拆分C-x 2
  2. 我使用其中一个打开终端M-x term ENT
  3. 如何使用键盘切换到不同的拆分?

通常的快捷方式显然不起作用 - 终端正在拦截每个 emacs 命令,我必须单击不同的缓冲区来激活它。

4

5 回答 5

159

在术语模式下,任何常规C-x whatever键绑定都会变成C-c whatever

于 2010-01-31T22:59:36.570 回答
12

我不确定我是否理解你的问题。如果你运行M-x terminal,大部分关键事件都会发送到底层终端,因此标准C-x o绑定和你M-Left在终端中不可用。

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

于 2010-01-31T21:35:06.437 回答
10

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

这就是 Cx b RET 通常做的事情。

于 2010-01-31T23:18:20.853 回答
6

这应该可以使 Cx 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程序。他们都有自己的位置。

于 2010-02-27T21:07:48.543 回答
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.
于 2010-02-01T18:23:41.157 回答