Emacs,切换到上一个窗口

Rog*_*son 92 emacs

在Emacs中,C-x o带我到下一个窗口.

什么键盘宏将我带到Emacs的上一个窗口?

Nat*_*ate 102

您可能还想尝试使用windmove,它可以让您根据几何体导航到您选择的窗口.我在.emacs文件中有以下内容,使用Cx箭头键更改窗口.

(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <right>") 'windmove-right)
(global-set-key (kbd "C-x <left>") 'windmove-left)
Run Code Online (Sandbox Code Playgroud)

  • 请注意,调用`(windmove-default-keybindings)`将这些函数绑定到SHIFT +上/下/左/右,我认为这比你的`Cx`绑定更方便(这与`的有用的默认绑定相冲突.前一个缓冲区`和`下一个缓冲区`.lkahtz:`(kbd)`函数允许你用更易读的语法指定字符串表示法中的键,当你使用`Ch k`或`Ch c时,Emacs也使用它`描述一个绑定. (11认同)
  • 我不赞成使用箭头键.但无论如何,我还是赞成有用.:踌躇满志: (4认同)
  • @phils SHIFT + &lt;keys&gt;与默认情况下从Emacs 23(shift-selection-mode)启用的换档选择混合在一起。 (2认同)
  • legends2k:是的;尽管您也可以将参数传递给`windmove-default-keybindings`来指定与箭头键结合使用的其他修饰符;因此该功能对于使用班次选择模式的人仍然非常方便。 (2认同)

JB.*_*JB. 86

那就是 C-- C-x o

换句话说,C-x o参数为-1.您可以通过C-u在命令之间插入数字参数来指定要移动的窗口数,如C-u 2 C-x o.(C--是一个快捷方式C-u - 1)


oco*_*odo 29

我个人更喜欢使用 window-number.el

要选择其他窗口,请使用Ctrl- x,Ctrl- j n

其中n是窗口的编号,每个窗口的模式行显示它的编号,如屏幕截图所示.

只需下载window-number.el,将其放在emacs加载路径中,然后在您的.emacs

 (autoload 'window-number-mode "window-number"
   "A global minor mode that enables selection of windows according to
 numbers with the C-x C-j prefix.  Another mode,
 `window-number-meta-mode' enables the use of the M- prefix."
   t)
Run Code Online (Sandbox Code Playgroud)

还有另一个类似的模式switch-window.el,它会在窗口中显示大数字...(按下数字会切换窗口并恢复显示.)

http://tapoueh.org/images/emacs-switch-window.png

  • 很好,但我建议不要将某些东西绑定到`Cx Cj`,因为如果你`(要求'dired-x)`那就是`dired-jump`的默认绑定.(如果要覆盖它,请参阅`Mx customize-group RET dired-keys RET`.) (2认同)

oct*_*cti 12

如果你经常使用多个emacs窗口(> 3),你会想要保存一些击键,将它添加到你的init文件中,你会更好:

(defun frame-bck()
  (interactive)
  (other-window-or-frame -1)
)
(define-key (current-global-map) (kbd "M-o") 'other-window-or-frame)
(define-key (current-global-map) (kbd "M-O") 'frame-bck)
Run Code Online (Sandbox Code Playgroud)

现在只需用Mo快速穿过窗户


小智 11

这里有一些非常好的和完整的答案,但要以极简主义的方式回答这个问题:

 (defun prev-window ()
   (interactive)
   (other-window -1))

 (define-key global-map (kbd "C-x p") 'prev-window)
Run Code Online (Sandbox Code Playgroud)

  • 我不知道从什么时候开始,但是 emacs 现在内置了“previous-window”。 (2认同)