[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rotate split windows

From: Markus Triska
Subject: Re: rotate split windows
Date: Mon, 04 Dec 2006 20:54:37 +0100

"wim yedema" <address@hidden> writes:

> I would like to be able to "rotate" the split between windows, eg:
> from (A, B) vertical to (A, B) horizonal, to (B, A) vertical, to (B,
> A) horizontal, and the other way around. Can anyone tell me how to
> do this?

Add this to your .emacs:

(defun rotate-split ()
  (let ((root (car (window-tree))))
    (if (listp root)
        (let* ((w1 (nth 2 root))
               (w2 (nth 3 root))
               (b1 (window-buffer w1))
               (b2 (window-buffer w2)))
          (cond ((car root)             ; currently vertically split
                 (delete-window w2)
                 (set-window-buffer (split-window-horizontally) b2))
                (t                      ; currently horizontally split
                 (delete-window w1)
                 (set-window-buffer (split-window-vertically) b1))))
      (message "Root window not split"))))

and invoke it with M-x rotate-split.

You can add this:

(global-set-key [f9] 'rotate-split)

to bind it to the function key F9 (for example).

The clockwise direction is analogous.

All the best,
Markus Triska

reply via email to

[Prev in Thread] Current Thread [Next in Thread]