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?
2 Answers
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?– twodeeCommented Sep 12, 2016 at 16:32 -
1
-
@Dan thank you, I found out
windmove
in another emacs question.– twodeeCommented Sep 12, 2016 at 16:43 -
The ErgoEmacs link covers that, among other things. Glad to help!– JCCCommented Sep 12, 2016 at 18:40
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))