Emacs move around split windows in a specified direction?

后端 未结 7 1084
陌清茗
陌清茗 2020-12-17 10:38

In Terminal Emacs (no mouse), I\'m using split windows to work with multiple buffers at the same time. I\'m finding moving between the split windows much more painful than h

相关标签:
7条回答
  • 2020-12-17 10:43

    Add this to your init file:

    (windmove-default-keybindings)
    

    Then you can use SHIFT+arrow to move to the next adjacent window in the specified direction.

    You can specify a different modifier if you prefer, by passing an argument (defaults to 'shift).

    Or just bind whatever you like to these functions:

    • windmove-up
    • windmove-down
    • windmove-left
    • windmove-right

    You can also add FrameMove to the mix, to make this work transparently across multiple frames.

    For numbered window navigation, there's switch-window.el.

    0 讨论(0)
  • 2020-12-17 10:44

    You can give a prefix argument to C-x o like this C-u -1 C-x o. This way you can go any number of windows forward or backward. Personally I think it's easier to create a special key for moving back one window. I have this in my .emacs:

    (defun other-window-backward ()
      "Goto previous window"
      (interactive)
      (other-window -1))
    (global-set-key (kbd "\C-x p") 'other-window-backward)
    
    0 讨论(0)
  • 2020-12-17 10:47

    For the sake of completion, there is window-numbering and ace-window too

    0 讨论(0)
  • 2020-12-17 10:52

    I use the following to navigate to the next (same as C-x o), previous, first, and last window:

    (defun my-previous-window ()
      "Previous window"
      (interactive)
      (other-window -1))
    (global-set-key "\C-xp" 'my-previous-window)
    
    (global-set-key "\C-xn" 'other-window)
    
    (defun my-select-first-window ()
      (interactive)
      (select-window (frame-first-window)))
    
    (defun my-select-last-window ()
      (interactive)
      (select-window (previous-window (frame-first-window))))
    
    (global-set-key "\C-x<" 'my-select-first-window)
    (global-set-key "\C-x>" 'my-select-last-window)
    
    0 讨论(0)
  • 2020-12-17 10:53

    Use window-jump, e.g.:

    ;; C-x <direction> to switch windows
    (use-package window-jump
                 :bind (("C-x <up>" . window-jump-up)
                        ("C-x <down>" . window-jump-down)
                        ("C-x <left>" . window-jump-left)
                        ("C-x <right>" . window-jump-right)))
    

    For help with use-package, see https://github.com/jwiegley/use-package/blob/master/README.md.

    0 讨论(0)
  • 2020-12-17 10:55

    Add this to your init file (e.g. ~/.emacs):

    (windmove-default-keybindings)
    

    Then do SHIFT+arrow to move to the window in that direction.

    0 讨论(0)
提交回复
热议问题