emacs split into 3 even windows

Solution 1:

C-x 3 twice followed by C-x + to equally size all windows.

Solution 2:

To specify the number of characters in the split window, do:

C-u number-of-characters C-x 3

Solution 3:

I have the following in my .emacs:

(defadvice split-window-horizontally (after rebalance-windows activate)
  (balance-windows))
(ad-activate 'split-window-horizontally)

this makes emacs call rebalance-windows (which is what C-x + is bound to by default) after every resize. It's not what I want all the time, but I want it much more often than the default behavior.

Solution 4:

add in .emacs. I mapped to C-x 4, but anyone has a better idea?

(defun split-3-windows-horizontally-evenly ()
  (interactive)
  (command-execute 'split-window-horizontally)
  (command-execute 'split-window-horizontally)
  (command-execute 'balance-windows)
)

(global-set-key (kbd "C-x 4") 'split-3-windows-horizontally-evenly)

Solution 5:

(defun wenshan-split-window-vertical (&optional wenshan-number)
"Split the current window into `wenshan-number' 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))

This function can be used to split the current window into N windows, you can type "C-u 3 M-x wenshan-split-window-vertical" to achieve what you want.