Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: How can I easily create a new window that spans two existing horizontal windows?

Tags:

emacs

I often have an Emacs frame that is partitioned into two windows like so:

--------------------------------
|                              |
|          Window 1            |
|                              |
|------------------------------|
|                              |
|          Window 2            |
|                              |
--------------------------------

Then I find myself needing a long vertical window that runs the entire height of the frame, like so:

--------------------------------
|         |                    |
| W'dow 3 |      Window 1      |
|         |                    |
|         |--------------------|
|         |                    |
|         |      Window 2      |
|         |                    |
--------------------------------

However, using C-x 3 it's only possible to split either Window 1 or Window 2. The only way to create the long vertical Window 3 is to start again with a single window filling the entire frame, and split it horizontally (then split one of the windows in half again, vertically). This is annoying.

I guess what I'm looking to do is to split the entire frame, rather than just the active window. I've Googled for solutions, but without success. Is it possible to create a new window that runs down the entire length of an Emacs frame, regardless of any windows that already exist inside it?

like image 772
FixMaker Avatar asked Oct 31 '22 22:10

FixMaker


2 Answers

(split-window 
  (frame-root-window) 
  nil 'left)
like image 60
Doerthous Avatar answered Dec 03 '22 02:12

Doerthous


This works:

(defun complex-split ()
  (interactive)
  (let (
        (thisBuffer (buffer-name))
        otherBuffer
        )
  (other-window 1)
  (setq otherBuffer (buffer-name))
  (delete-other-windows)
  (split-window-horizontally)
  (other-window 1)
  (split-window-vertically)
  (switch-to-buffer thisBuffer)
  (other-window 1)
  (switch-to-buffer otherBuffer)
  )
)
like image 31
Adobe Avatar answered Dec 03 '22 00:12

Adobe