Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to retile buffer windows in Emacs?

Tags:

emacs

I have two buffer windows open in emacs, arranged vertically. Is there a command that rearranges them horizontally?

like image 274
David Zureick-Brown Avatar asked Dec 27 '11 19:12

David Zureick-Brown


People also ask

How do you change from one buffer to another?

To move between the buffers, type C-x b. Emacs shows you a default buffer name. Press Enter if that's the buffer you want, or type the first few characters of the correct buffer name and press Tab.

How do I change windows in Emacs?

To select a different window, click with Mouse-1 on its mode line. With the keyboard, you can switch windows by typing C-x o ( other-window ).

Is it true you can only have one buffer open in Emacs at a time?

Each Emacs window displays one Emacs buffer at any time. A single buffer may appear in more than one window; if it does, any changes in its text are displayed in all the windows where it appears. But the windows showing the same buffer can show different parts of it, because each window has its own value of point.

How do I switch between buffers in Emacs?

For conveniently switching between a few buffers, use the commands C-x <LEFT> and C-x <RIGHT> . C-x <RIGHT> ( previous-buffer ) selects the previous buffer (following the order of most recent selection in the current frame), while C-x <LEFT> ( next-buffer ) moves through buffers in the reverse direction.


3 Answers

The Transpose Frame library provides an excellent set of functionality for manipulating the windows in a frame (any of transpose-frame, rotate-frame-clockwise, or rotate-frame-anti-clockwise would suffice for your particular example).

There are other alternatives, but I find this library fairly comprehensive. See the Wiki page (or the Commentary in the code) for ascii drawings of what each function does.

like image 161
phils Avatar answered Nov 01 '22 19:11

phils


I use following snippet taken from Emacs wiki:

(defun toggle-window-split ()
  (interactive)
  (if (= (count-windows) 2)
      (let* ((this-win-buffer (window-buffer))
         (next-win-buffer (window-buffer (next-window)))
         (this-win-edges (window-edges (selected-window)))
         (next-win-edges (window-edges (next-window)))
         (this-win-2nd (not (and (<= (car this-win-edges)
                     (car next-win-edges))
                     (<= (cadr this-win-edges)
                     (cadr next-win-edges)))))
         (splitter
          (if (= (car this-win-edges)
             (car (window-edges (next-window))))
          'split-window-horizontally
        'split-window-vertically)))
    (delete-other-windows)
    (let ((first-win (selected-window)))
      (funcall splitter)
      (if this-win-2nd (other-window 1))
      (set-window-buffer (selected-window) this-win-buffer)
      (set-window-buffer (next-window) next-win-buffer)
      (select-window first-win)
      (if this-win-2nd (other-window 1))))))

(define-key ctl-x-4-map "t" 'toggle-window-split)

Just put this into init.el and use Ctrl-x 4 t.

like image 44
Xaerxess Avatar answered Nov 01 '22 21:11

Xaerxess


You asked about tiling windows in a frame. Others will answer you directly about that (C-x 3 is a start). But you might also want to know that you can use separate frames and tile the frames across or down your display.

like image 39
Drew Avatar answered Nov 01 '22 21:11

Drew