28

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?

7
  • 4
    Are we intentionally duplicating questions from SO? stackoverflow.com/questions/4987760/…
    – phils
    Oct 1, 2014 at 22:07
  • @phils, No I was not. But I will make a link to the post. Thank you for the insight. Oct 1, 2014 at 22:08
  • beyond that, that one was a little bit too easy :)
    – Nsukami _
    Oct 1, 2014 at 22:17
  • 1
    Gee, great edit @King. Now this question has become really different from the one you copied...
    – rsenna
    Oct 1, 2014 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, 2014 at 0:12

5 Answers 5

55

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)

3
  • 1
    +1 for the shrinking command. I was looking for the way to shrink by a single line. What is C-u?
    – Vass
    Sep 18, 2016 at 22:28
  • 4
    @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, 2016 at 7:01
  • 2
    It's also worth noting that C-u default value is 4, meaning that C-u C-x ^ will do the same as C-u 4 C-x ^.
    – ramnes
    Aug 1, 2019 at 8:27
13

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.

5

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.

1
  • great idea to make another window smaller by enlarging the one above it!
    – Vass
    Sep 18, 2016 at 22:29
1

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)

1

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 agree to our terms of service and acknowledge you have read our privacy policy.

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