当前位置: 动力学知识库 > 问答 > 编程问答 >

keyboard shortcuts - How to switch between visible buffers in emacs?

问题描述:

I feel stupid for not being able to find this but no tutorial I found actually gives me the short-cut key or command.

If I am in split-screen viewing 2 different buffers on emacs and the cursor is on the top buffer, whats 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?

网友答案:

To switch to other buffer use C-x o

Describe key C-h k

网友答案:

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.

网友答案:

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.

网友答案:

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

网友答案:

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?

分享给朋友:
您可能感兴趣的文章:
随机阅读: