Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to swap the buffers in 2 windows emacs

Tags:

emacs

I am using emacs I find that sometimes I have 2 files separated into 2 windows.

For example: I open 1 file using C-x C-f file1.c RET

and I split the frame into two windows: C-x 3

I then open another file C-x C-f file2.c RET

So I have 2 files:

window 1 (left) file1.c

window 2 (right) file2.c

I am wondering if there is any key combination to swap the files over? Normally I like to work on the left window when I have 2 window. I know I can easily do C-x oto move the cursor to the right window.

However, I am just wondering if I can swap the files so that file2.c is in the left window and file1.c is in the right window?

like image 868
ant2009 Avatar asked Nov 21 '09 07:11

ant2009


People also ask

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).

How do I switch between files in Emacs?

Switching between files is much more comfortable within a single emacs session. Much better to use the multiple buffer feature of emacs. If you are editing the first file and want to start editing the second file, simply use the hot key C-x C-f or the menu selection File->Open File to start the second file.

How do I open multiple Emacs windows?

You can split a window horizontally or vertically by clicking C-Mouse-2 in the mode line or the scroll bar.

How many buffers can you have in Emacs?

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.


1 Answers

I use buffer-move for this. Now if you are working on the buffer on the left side, calling 'buf-move-right' will swap it with the one on the right. I guess this is what you want.

like image 147
Raja Selvaraj Avatar answered Sep 21 '22 13:09

Raja Selvaraj