2

I just started using emacs and since I have been using Sublime Text for a while, I am used to the four-grid-layout with 4 windows stacked horizontally and vertically. I have been able to split the screen horizontally only. How do I split it 4 ways?

4

To split the window in half with a vertical divider, use the command split-window-right. To split it in half with a horizontal divider, use the command split-window-below.

For example, assume we have this window by default:

.-------------.
|             |
|             |
|             |
|             |
|             |
'-------------'

M-x split-window-right RET:

.-------------.
|      |      |
|      |      |
|      |      |
|      |      |
|      |      |
'-------------'

M-x split-window-below RET:

.-------------.
|             |
|             |
|-------------|
|             |
|             |
'-------------'

split-window-right is bound to C-x 3 by default. split-window-below is bound to C-x 2 by default.

ErgoEmacs has a good guide on window management and navigation, including how to save a specific arrangement (e.g. a 4-way split) and load it automatically.

  • Thanks for that. It works. How do I jump from one window to the other without C-X o. Say, I want to jump to the right window to the current one, how do I do that? – 2dsharp Sep 12 '16 at 16:32
  • 1
    @CoderDudeTwodee: in general, please post a separate question rather than follow up in comments. In this case, though, you could consider using windmove. – Dan Sep 12 '16 at 16:40
  • @Dan thank you, I found out windmove in another emacs question. – 2dsharp Sep 12 '16 at 16:43
  • The ErgoEmacs link covers that, among other things. Glad to help! – jcaw Sep 12 '16 at 18:40
4

Use the split-window-xxx commands, as described in another answer. If you always want a grid of 4 windows, here's a command you could use:

(defun split-4-ways ()
  (interactive)
  (delete-other-windows)
  (split-window-right)
  (split-window-below)
  (windmove-right)
  (split-window-below)
  (windmove-left))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.