szli
szli

Reputation: 39079

Opening same file in two windows in Emacs

Say I have opened a file abc.cpp in one Emacs window, I want to open it in another window. If I do C-x C-f and locate the file, the cursor goes back to the original window and the file does not open in the window where I placed my cursor. If I do C-x b and identify the buffer, the cursor goes to the original window as well. I hope I can put my cursor in some other window, and open the file in that window, no matter whether the file is opened already. How can I do that? One way that seems to work is to use mouse, go to File menu and choose Open File, but that is not very nice...

Upvotes: 2

Views: 1191

Answers (2)

Diego Sevilla
Diego Sevilla

Reputation: 29001

Alternatively to what @vonbrand said, you can always call new-frame (M-x new-frame) and the current opened file will open in a new frame (window).

Upvotes: 1

vonbrand
vonbrand

Reputation: 11791

That one is easy! The command C-x 2 will split the window showing the buffer in two horizontally. The relevant command is split-window-vertically.

Upvotes: 4

Related Questions