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

Emacs 如何从终端缓冲区切换到不同的缓冲区,emacs,emacs23,Emacs,Emacs23,我已经使用emacs几个星期了,到目前为止,它非常棒-来自vim比我预期的要容易(实际上-emacs的键盘快捷键感觉更…自然) 我添加了一些定制,比如使用M-Left/Right/Up/Down在缓冲区之间移动,因为C-xo在同时打开四个文件时感觉有点太慢了 到目前为止-很好:-) 但有一件事让我很烦: 我使用C-x 3和C-x 2 我使用M-x term ENT 如何使用键盘切换到不同的分割 通常的快捷方式显然不起作用-终端正在拦截每个emacs命令,我必须单击不同的缓冲区才能激活它。我不确定

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

我添加了一些定制,比如使用
M-Left/Right/Up/Down
在缓冲区之间移动,因为
C-xo
在同时打开四个文件时感觉有点太慢了

到目前为止-很好:-)

但有一件事让我很烦:

  • 我使用
    C-x 3
    C-x 2
  • 我使用
    M-x term ENT
  • 如何使用键盘切换到不同的分割
    通常的快捷方式显然不起作用-终端正在拦截每个emacs命令,我必须单击不同的缓冲区才能激活它。

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


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

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

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


    这正是C-x b RET通常所做的。

    有关emacs窗口的更一般的回答,您可以查看
    windmove
    ,它大约在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.
    

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

    (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模式和term模式有很大的区别。前者更好地与emacs集成(例如cd命令)。后者是一个完整的终端仿真,可以处理curses程序。他们都有各自的位置。

    谢谢-这解决了我的问题。我不知道M X shell和M X术语之间有什么区别。特别是,一个得救的罪人特别欢迎Emacs的教会。你应该考虑使用IswitCH缓冲区来改变缓冲区而不是使用多个窗口。它的生产效率要高得多。Emacs“窗口”是您在执行
    C-x 2
    等操作时得到的东西。顶级应用程序窗口在Emacs语言中称为“框架”。@NoufalIbrahim为什么不能两者兼而有之?通常,为了有效地工作,我需要同时查看两个文件或两段代码,两个窗口非常适合这样做。然后
    i完成模式
    切换缓冲区(它取代了24.4中的iswitch缓冲区:)@ramy我在大约10年前问过这个问题:-)现在我使用ace window软件包在可见缓冲区之间快速跳转这应该会得到更多的支持-有时需要m-x term和m-x shell之间的差异-例如,使用watch命令来监视不断变化的数据(除非有更好的emacs方法可以这样做)。非常正确,我当前的问题是我已经将窗口切换绑定到C-f/b/n/p,但当我在任期内时,我无法切换出去!有人知道为什么会这样吗?为什么不像往常一样使用C-x(stty-a命令不显示C-x的绑定)。对否决票表示歉意。我误读了答案,认为它是错误的。不幸的是,我意识到太晚了,否决票现在被锁定。