How to switch between visible buffers in emacs?

為{幸葍}努か 提交于 2019-11-27 00:25:59

问题


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 question: if I know a command, is there an easy way to identify what key-combo it's bound to, if any?


回答1:


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

Describe key: C-h k.




回答2:


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.




回答3:


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




回答4:


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.




回答5:


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?



来源:https://stackoverflow.com/questions/4671819/how-to-switch-between-visible-buffers-in-emacs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!