在Emacs中更快地更改窗口(或通过单击执行重复最后一个快捷方式)

时间:2011-02-18 21:08:53

标签: emacs keyboard-shortcuts

如果我想改变emacs中的窗口,我会做Cx o,这对我很好......但是当我想连续多次更改窗口时Cx o不太方便...有没有办法在第一次Cx o之后只用一次罢工改变窗口? 一般来说......是否有(单一)罢工会重复我最后的捷径?

4 个答案:

答案 0 :(得分:6)

我使用C-tab切换窗口:

(global-set-key [C-tab] 'other-window)

按住Control键,只需按Tab键即可反复跳转窗口。

编辑:我的原始答案包含以下内容

  
    

我认为没有一种内置方法可以为这样的基本命令重复上一个命令...

  

这不再是真的。 Emacs现在包含repeat.el,它允许rabidmachine9要求的行为。

以下代码将创建重复的other-window,以便在第一次按C-x o后,再次按o将继续移至下一个窗口。

(require 'repeat)
(defun make-repeatable-command (cmd)
  "Returns a new command that is a repeatable version of CMD.
The new command is named CMD-repeat.  CMD should be a quoted
command.

This allows you to bind the command to a compound keystroke and
repeat it with just the final key.  For example:

  (global-set-key (kbd \"C-c a\") (make-repeatable-command 'foo))

will create a new command called foo-repeat.  Typing C-c a will
just invoke foo.  Typing C-c a a a will invoke foo three times,
and so on.

See related discussion here: 
http://batsov.com/articles/2012/03/08/emacs-tip-number-4-repeat-last-command/#comment-459843643
https://groups.google.com/forum/?hl=en&fromgroups=#!topic/gnu.emacs.help/RHKP2gjx7I8"
  (fset (intern (concat (symbol-name cmd) "-repeat"))
        `(lambda ,(help-function-arglist cmd) ;; arg list
           ,(format "A repeatable version of `%s'." (symbol-name cmd)) ;; doc string
           ,(interactive-form cmd) ;; interactive form
           ;; see also repeat-message-function
           (setq last-repeatable-command ',cmd)
           (repeat nil)))
  (intern (concat (symbol-name cmd) "-repeat")))

(global-set-key (kbd "C-x o") (make-repeatable-command 'other-window))

函数make-repeatable-command用于创建其他重复命令,使用相同的模板。

答案 1 :(得分:5)

查看windmove;它让你只需按住一个修改键,然后按箭头键移动到那个方向的窗口。我已经使用默认修饰符(移位)多年了,奇怪的是它不会干扰我在其他应用程序中使用移位箭头文本选择的冲动。

帧中还有一个equivalent,我应该尝试一下......

答案 2 :(得分:4)

你在框架中有10个窗口,你连续多次做M-x other-window,我认为你要跳过,比如窗口#2到窗口#8然后在窗口#1等等。通过连续执行大量other-window,我认为在达到所需窗口之前,您不会做任何重要的事情。

查看绑定到universal-argument的{​​{1}}是否有帮助。在10窗口框架中,如果你在#3窗口并想要转到窗口#9,你将跳到第6个下一个窗口。所以你会做C-u。或者,你也可以C-u 6 C-x o从#3窗口到达#9窗口。

答案 3 :(得分:4)

派对迟到了,但也有window-numbering(在MELPA中称为'window-number')。

这包括模式行-1--2-等中的窗口编号,并提供M-1M-2等密钥绑定以直接选择它们。很快。