Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch between visible buffers in emacs?

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?

like image 958
George Mauer Avatar asked Jan 12 '11 17:01

George Mauer


People also ask

How do I switch between buffers in Emacs?

To move between the buffers, type C-x b. Emacs shows you a default buffer name. Press Enter if that's the buffer you want, or type the first few characters of the correct buffer name and press Tab. Emacs fills in the rest of the name.

Can you have more than one buffer in Emacs?

When Emacs has multiple windows, each window has a chosen buffer which is displayed there, but at any time only one of the windows is selected and its chosen buffer is the selected buffer. Each window's mode line displays the name of the buffer that the window is displaying (see section Multiple Windows).

Can you only have one buffer open in Emacs at a time?

Each Emacs window displays one Emacs buffer at any time. A single buffer may appear in more than one window; if it does, any changes in its text are displayed in all the windows where it appears.

How many buffers can be open in Emacs at a time?

This is because Emacs tracks buffer positions using that data type. For typical 64-bit machines, this maximum buffer size is 2^{61} - 2 bytes, or about 2 EiB. For typical 32-bit machines, the maximum is usually 2^{29} - 2 bytes, or about 512 MiB.


2 Answers

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

Describe key: C-h k.

like image 152
Rozuur Avatar answered Sep 25 '22 12:09

Rozuur


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.

like image 33
CodyChan Avatar answered Sep 22 '22 12:09

CodyChan