In standard Emacs, pressing C-x 3 will call function split-window-right to split the current window into two identical windows. Sometimes I want to get more than two windows, so I wrote this little function:

(defun wenshan-split-window-vertical (&optional wenshan-number)
  "Split the current window into `wenshan-number' windows and balance all windows"
  (interactive "P")
  (setq wenshan-number (if wenshan-number(prefix-numeric-value wenshan-number)2))
  (while (> wenshan-number 1)
    (split-window-right)
    (setq wenshan-number (- wenshan-number 1)))
  (balance-windows))

It calls split-window-right multiple times to get multiple new windows and finally calls balance-window to adjust the sizes of all windows. eval this function, then you could press M-x wenshan-split-window-vertical (thanks to the auto-completion functionality, you won’t need to type all these characters) to call it.


Reference:

  1. Delete the file corresponding to the current buffer
  2. Alarm for Breaks
  3. Insert source code block in org-mode
  4. Edit current file as root
  5. Getting rid of mouse

My site is free of ads and trackers. Was this post helpful to you? Why not BuyMeACoffee