9

If I have Emacs split horizontally and on top I'm editing elisp code and on the bottom I am in the shell. By default, Emacs makes the two windows equal in size, but I'd like the shell buffer smaller. I was wondering how I could do that.

Original question asked by Steve on SO: How to Change size of split screen emacs windows?

  • 3
    Are we intentionally duplicating questions from SO? stackoverflow.com/questions/4987760/… – phils Oct 1 '14 at 22:07
  • @phils, No I was not. But I will make a link to the post. Thank you for the insight. – Luke Oct 1 '14 at 22:08
  • beyond that, that one was a little bit too easy :) – Nsukami _ Oct 1 '14 at 22:17
  • 1
    Gee, great edit @King. Now this question has become really different from the one you copied... – rsenna Oct 1 '14 at 22:32
  • 2
    it make me think that, the emacs related questions on SO should be migrated. It will have avoided the (tiny) uproar – Nsukami _ Oct 2 '14 at 0:12
15

C-x- (shrink-window-if-larger-than-buffer) to shrink a window to fit its content.

C-x+ (balance-windows) to make windows the same heights and widths.

C-x^ (enlarge-window) to increase height by 1 line, or the prefix arg value. A negative arg shrinks the window. Example: C-u - 3 C-x ^

C-x{ (shrink-window-horizontally)

C-x} (enlarge-window-horizontally)

  • +1 for the shrinking command. I was looking for the way to shrink by a single line. What is C-u? – Vass Sep 18 '16 at 22:28
  • 2
    @Vass C-u begin a numeric argument for the following command. If you want to increase 5 times, instead of typing, 5 times, the same command, you type C-u 5 C-x ^ – Nsukami _ Sep 20 '16 at 7:01
4

I would also recommend checking out either the windresize package from ELPA, or the windsize package from MELPA.

With windresize, you can do M-x windresize and then use the arrow keys to move window borders easily, hitting ENTER when you're done.

1

You can use C-x^ (enlarge-window) in the upper window to make it larger (and thus make the lower window smaller).

Using the mouse, you can also drag the modeline of the upper window to resize it.

  • great idea to make another window smaller by enlarging the one above it! – Vass Sep 18 '16 at 22:29
0

Also note that just like in a window system, you can use the mouse with xterm-mouse-mode to drag the window divider.

Note that this seems to sometimes depend a bit on the actual xterm or xterm-like program, and iirc in older Emacsen it wasn't reliable past about the 100th column unless you played with the TERM environment variable a bit, but in my Emacs 24.2.1 it works fine with emacs -nw -q (ie. totally ignoring my .emacs and manually enabling xterm-mouse-mode with M-x xterm-mouse-mode)

Update: FYI for completeness I'll point out this also works for vertical dividers (ie. when you have split with C-x 3)

0

I've ever written a simple minor-mode (for my personal usage) to interactively resize-frame. I think this should be convenient.

https://gist.github.com/kuanyui/65a408d393871048771c

M-x resize-frameto enable the resize-frame minor-mode:

  1. Press arrow keys to adjust size horizontally/vertically.
  2. Press any other keys to disable.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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