29

I'm interested how can I resize split windows in emacs when I'm in console mode?

I opened my file with:

emacs myfilename.txt -nw

now when I split my window with:

C-x 2 

or

C-x 3

how can I resize new windows?

phils
  • 71,335
  • 11
  • 153
  • 198
Headshota
  • 21,021
  • 11
  • 61
  • 82
  • 1
    This question could be rephrased as "how to resize emacs window with keyboard commands" or similar. – Gerstmann Jun 11 '11 at 18:07
  • 1
    Possible duplicate of [How to Change size of split screen emacs windows?](http://stackoverflow.com/q/4987760/324105) – phils Jan 14 '13 at 03:47

3 Answers3

50

Try M-x enlarge-window and M-x shrink-window.

You can specify the number of lines by which to enlarge or shrink with the prefix argument, e.g. to enlarge a window by six lines, type:

C-u 6 M-x enlarge-window

By default enlarge-window is bound to C-x ^. shrink-window is not bound to any shortcut by default, but you can use a negative prefix argument with C-x ^ to get shrinkage.

So you could get the same effect as above by typing:

C-u 6 C-x ^ (enlarge)

C-u - 6 C-x ^ (shrink)


A special case is the horizontal split where you have additional keyboard shortcuts available for embiggening or shrinking the windows:

C-x } is bound to enlarge-window-horizontally

C-x { is bound to shrink-window-horizontally

Again, you can use prefix arguments to specify the amount (i.e., number of columns) you want to enlarge/shrink the windows with C-u

Thomas
  • 17,016
  • 4
  • 46
  • 70
32

If you split window vertically with C-x 2, use C-x ^ and M-x shrink-window. If you split horizontally with C-x 3, use C-x { and C-x } to enlarge and shrink.

Chang Peng
  • 1,052
  • 8
  • 14
6

In addition to shrink-window and enlarge-window, you can also use enlarge-window-horizontally and shrink-window-horizontally.

Personally I bind these like this:

(global-set-key (kbd "A-<down>") 'enlarge-window)
(global-set-key (kbd "A-<up>") 'shrink-window)
(global-set-key (kbd "A-<left>") 'enlarge-window-horizontally)
(global-set-key (kbd "A-<right>") 'shrink-window-horizontally)

Then it's very easy to resize -nw window splits using alt-arrow keys. Also you can just hold the keys down to repeat the command, I find this easier than having to think about how many repeats I want (i.e. using C-u 10 etc).

(more info http://www.emacswiki.org/emacs/WindowResize)

danf
  • 91
  • 1
  • 2
  • What does "A" mean? Do you mean "M" (Meta), which is in most cases of modern keyboards the "Alt" key? – buhtz May 01 '23 at 11:29