Dua solusi di sini, gunakan salah satu yang Anda suka:
J: Secara vertikal (kiri / kanan) secara default:
(setq split-height-threshold nil)
(setq split-width-threshold 0)
B: Secara otomatis membagi jendela secara vertikal (kiri / kanan) jika jendela saat ini cukup lebar
(defun display-new-buffer (buffer force-other-window)
"If BUFFER is visible, select it.
If it's not visible and there's only one window, split the
current window and select BUFFER in the new window. If the
current window (before the split) is more than 100 columns wide,
split horizontally(left/right), else split vertically(up/down).
If the current buffer contains more than one window, select
BUFFER in the least recently used window.
This function returns the window which holds BUFFER.
FORCE-OTHER-WINDOW is ignored."
(or (get-buffer-window buffer)
(if (one-window-p)
(let ((new-win
(if (> (window-width) 100)
(split-window-horizontally)
(split-window-vertically))))
(set-window-buffer new-win buffer)
new-win)
(let ((new-win (get-lru-window)))
(set-window-buffer new-win buffer)
new-win))))
(setq display-buffer-function 'display-new-buffer)
Taruh siapa pun di .emacs/init.elfile Anda . Anda dapat mengubah "100" ke nilai yang Anda suka, tergantung pada layar Anda.
Jika Anda memiliki dua jendela dalam satu bingkai, dan Anda ingin mengubah tata letak dari vertikal ke horizontal atau sebaliknya, berikut solusinya:
(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)
Taruh di .emacs/init.elfile Anda , Gunakan C-x 4 tuntuk mengubah tata letak jendela Anda.