next up previous
Next: Emacs C++ mode coding Up: emacs Previous: Editing more than one


Splitting windows and creating frames

Sometimes it is useful to view two files (or two parts of the same file) at once. This can be done by splitting the window or by creating a new frame.

Splitting windows

To split a window, use the command C-x 2 or the menu selection File->Split Window. This command divides the window into an upper and lower panel. Each panel has its own title bar.

When you first do this, you will be seeing double - you will see the same part of the same file in the upper and lower panel. If you edit the file, the changes appear simultaneously in both panels. Only one panel is active at a time. To tell which one, you should examine the cursors, which appear in both windows. With our system, the cursor in the active window is a solid colored rectangle and in the inactive window it is a hollow rectangle. The cursors can be in different locations in the same file.

You can change the active panel by clicking in it with the mouse. This action will also move the cursor. Alternatively, you can toggle between active panels by typing C-x o (that's a little ``oh''). That command does not move the cursor, which is sometimes useful.

The active panel is the one that receives the commands. So to view a different file in the active panel, just switch buffers while the panel is active. Use the C-x b command or the Buffers menu. Or if you haven't opened the file, yet, use the C-x C-f command to open the new file in a new buffer.

To unsplit the window, use the command C-x 1 or right-click on either title bar. The inactive panel disappears.

Creating frames

If you need to view a larger portion of your file or files, you can create a whole new frame. This is done with the command C-x 5 2 or the menu selection File->New Frame. The result looks a lot like what you would get by running two emacs sessions, except there is really only one session, and there is no danger in editing the same file in both windows. The changes are applied immediately to both.

To delete the extra frame, use C-x 5 0 or the menu selection File->Delete Frame.

next up previous
Next: Emacs C++ mode coding Up: emacs Previous: Editing more than one
Carleton DeTar 2016-12-29