46
Window A
++++++++
Window B

Is there a way to switch to

Window A : Window B

Is there a way to switch view without closing windows?

Nick
  • 4,423
  • 4
  • 24
  • 41
  • 1
    With the large screens of today, why would one ever want to run something other than side-by-side windows? I use six windows spread out over two monitorns -- I use https://github.com/Lindydancer/multicolumn to set up the windows when I start Emacs and have configured most of my packages to reuse existing windows. – Lindydancer Nov 15 '16 at 10:42
  • 3
    Possible duplicate of [Switch window split orientation, fastest way](https://emacs.stackexchange.com/questions/318/switch-window-split-orientation-fastest-way) – TooTone Mar 18 '18 at 12:04
  • 3
    @Lindydancer it's not a good idea to second guess other people's needs based on your HW utilisation. How about some people stack monitors rather than have them side by side? ;) – RichieHH Feb 21 '20 at 22:23
  • Sometimes when your killing windows you end up with them vertically stacked and you'd like to get to get side by side. Every once in a while you want to compare two very long lined files and it also helps. – salotz Dec 19 '20 at 03:05

3 Answers3

25

Alternatively, there's a tranpose-frame package on EmacsWiki that will allow you to transpose the whole frame, as well as do other transformations (rotate by by 180 degrees; rotate by 90 degrees clockwise or counterclockwise; flip horizontally or vertically).

Dmitry
  • 3,508
  • 15
  • 20
21

The transpose-frame package is available on MELPA as well.

Use M-x transpose-frame, or bind it to something to accomplish this.

salotz
  • 1,370
  • 10
  • 21
17

Here's a simple function that will toggle between a horizontal and vertical split. It assumes you've only got two windows, and doesn't do any resizing:

(defun window-split-toggle ()
  "Toggle between horizontal and vertical split with two windows."
  (interactive)
  (if (> (length (window-list)) 2)
      (error "Can't toggle with more than 2 windows!")
    (let ((func (if (window-full-height-p)
                    #'split-window-vertically
                  #'split-window-horizontally)))
      (delete-other-windows)
      (funcall func)
      (save-selected-window
        (other-window 1)
        (switch-to-buffer (other-buffer))))))
Dan
  • 32,584
  • 6
  • 98
  • 168