How to switch between visible buffers in emacs?

前端 未结 5 2051
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 19:51

If I am in split-screen viewing 2 different buffers on Emacs and the cursor is on the top buffer, what\'s a quick way to move the cursor to the bottom buffer?

Bonus

相关标签:
5条回答
  • 2020-12-07 20:36

    To switch to other buffer use: C-x o.

    Describe key: C-h k.

    0 讨论(0)
  • 2020-12-07 20:36

    If you want to navigate among only buffers that are currently displayed, then you really want to navigate among the windows they are displayed in. This gives you a way to do that, using window/frame names that are the same as the buffers:

    See Better window navigation in Emacs?

    0 讨论(0)
  • 2020-12-07 20:47

    Here is a better solution when you open more than two windows(buffers) in one frame:

    (global-set-key (kbd "C-x <up>") 'windmove-up)
    (global-set-key (kbd "C-x <down>") 'windmove-down)
    (global-set-key (kbd "C-x <left>") 'windmove-left)
    (global-set-key (kbd "C-x <right>") 'windmove-right)
    

    Now, you can use C-x UP/DOWN/LEFT/RIGHT to go to the above/nether/left/right buffer when you have three or more in one frame, they are more precise than 'other-window and you don't need to install any package.

    You even CAN make it to cycle the buffers in the direction(vertically/horizontally) with one of the above shortkeys with configuration in .emacs/init.el file, but I don't recommend it(besides I don't remember it anymore, you can google it if you want).

    Of course, you can use other shortkeys other than the ones I use in my .emacs.

    0 讨论(0)
  • 2020-12-07 20:48

    With respect to the bonus question, if you know the command (other-window), and you invoke it with M-x other-window, Emacs will show a brief message in the minibuffer stating: "You can run the command `other-window' with C-x n".

    There is also M-x where-is which prompts for a command and gives you the current bindings that result in that command (if any).

    There is a tutorial that's shipped with Emacs. It actually has the answer to your question (see the section MULTIPLE WINDOWS about 80% into the tutorial). The tutorial can be accessed via C-h t, or M-x help-with-tutorial. There's also a link to the tutorial on the initial splash screen of Emacs. Right below the link to the tutorial is a link to the on-line Emacs Guided Tour. The tutorial walks you through basic editing/movement commands, the guided tour is more of an introduction to what Emacs has to offer.

    0 讨论(0)
  • 2020-12-07 20:56

    You may also be interested in WindMove, which enables "directional" window navigation with <S-up>, <S-right> etc.

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