【问题标题】:Better window navigation in Emacs?Emacs 中更好的窗口导航?
【发布时间】:2011-06-19 00:58:14
【问题描述】:

当我在 emacs 中多次拆分窗口时(在终端下),整个屏幕被分成几个层次排列的部分。在 vim 中,使用 Control-w + (h,j,k,l) 很容易在窗口之间直观地切换,但在 Emacs 中我只能使用 Control-x + o 切换到“另一个窗口”,这可能需要几次迭代最终到达我想要的窗口。我想知道是否有类似于 Vim 中的更好的方法来轻松地在窗口之间导航?

【问题讨论】:

    标签: vim emacs editor window


    【解决方案1】:

    switch-window。它会为窗口编号,让您直接切换到您想要的窗口。

    【讨论】:

    • 我投票赞成这个解决方案。 WinMove 与邪恶模式发生冲突,并且到达箭头键对我来说似乎比 C-x o [number] 慢(也许这只是心理上的)
    【解决方案2】:

    Icicles 中,默认情况下 C-x o 绑定到多命令 icicle-other-window-or-frame,其工作方式如下:

    • 没有前缀 arg 或非零数字前缀 arg: 如果选定的框架有多个窗口,那么这是 other-window。否则为other-frame

    • 使用零前缀 arg(例如 C-0): 如果选定的框架有多个窗口,那么这是 icicle-select-window 框架中的窗口作为候选。 否则(单窗口框架),这是icicle-select-frame

    • 使用普通 C-u: 如果选定的框架有多个窗口,那么这是 icicle-select-window 所有可见框架中的窗口为 候选人。否则,这是icicle-select-frame

    那么,icicle-select-windowicicle-select-frame 是什么?

    它们是多命令,可让您选择要按名称选择的窗口或框架。 (如果需要,您可以单独绑定它们——它们每个都根据自己的前缀 args 更改其行为。)

    窗口和框架名称取自它们显示的缓冲区,如果需要在多个窗口中显示相同的缓冲区,则附加 [N] (N=1,2,...) 以获得唯一名称/框架。

    作为多命令,您可以通过完成和/或循环来选择。补全可以是前缀、子字符串、正则表达式或模糊。

    http://www.emacswiki.org/emacs/Icicles_-_Multi-Commands

    【讨论】:

      【解决方案3】:

      我发现other-window 的默认绑定也非常乏味。我在.emacs 中定义了以下内容:

      (global-set-key [(control ?,)] (lambda () (interactive) (other-window -1)))
      (global-set-key [(control ?.)] (lambda () (interactive) (other-window 1)))
      

      只需找到一些易于访问的键绑定(我使用 Dvorak 布局,因此 C-,C-. 可能对您而言并不容易访问),最好彼此相邻,以绑定到那些 lambdas。

      另外,几个月前我找到了Emacs wikiNifty Tricks 提供了一系列使 Emacs 更易于使用的方法!

      【讨论】:

        【解决方案4】:

        这也是我第一次接触 emacs。但是,使用 windmove,我可以按照我想要的方式对其进行调整。我用它作为windmove的修饰符:

        (windmove-default-keybindings 'meta)
        

        windmove 的导航我用 ALT 键

        【讨论】:

          【解决方案5】:

          你试过WindMove吗?它与 Emacs 21+ 捆绑在一起。您可以使用 Shift-upShift-downShift-leftShift-right 来移动您可以更改修饰符。来自文档:

          ;; Installation:
          ;;
          ;; Put the following line in your `.emacs' file:
          ;;
          ;;     (windmove-default-keybindings)         ; shifted arrow keys
          ;;
          ;; or
          ;;
          ;;     (windmove-default-keybindings 'hyper)  ; etc.
          ;;
          ;; to use another modifier key.
          ;;
          ;;
          ;; If you wish to enable wrap-around, also add a line like:
          ;;
          ;;    (setq windmove-wrap-around t)
          

          【讨论】:

          猜你喜欢
          • 2010-10-10
          • 1970-01-01
          • 1970-01-01
          • 2011-07-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-11-13
          相关资源
          最近更新 更多