Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximize Emacs Windows Horizonatally or Vertically

I'm aware of C-x 1, which will maxamize the current window both horizontally and vertically.

However, my quesiton is, is it possible to expand the current window to the edge of the frame on one direction only?

So in the below I want to expand window A to the right border of the frame, taking up the space currently occupied by B and C. But I want D and E to remain untouched.... and I want to do it in a single command.

Excuse the terrible attempt at ASCII art!

 _______________________
| AAAAAA |BBBBBB |CCCC  |
|________|_______|______|
| DDDDD  | EEEEEEEEEE   |
|________|______________|

I know you can move horizontally 1 char at a time, and that you can use the repeat n times command to do this many times, but both are clunky, when what I really want to say is expand until the right hand border, I don't care how far that is.

The nearest I've come up with this to go to each frame occupying the space you want and calling C-X 0, but this is still a bit clunky.

I need this to work in terminal mode (emacs -nw) rather than graphical/X-Windows mode.

Any ideas?

like image 812
Phil Avatar asked Feb 03 '26 02:02

Phil


1 Answers

You can do this with library frame-cmds.el (description).

It provides these commands:

  • maximize-frame-horizontally, maximize-frame-vertically, and max-frame
  • restore-frame-horizontally, restore-frame-vertically, and restore-frame

The "restore" commands are actually toggles that alternate between maximizing and restoring. (They are aliased to commands toggle-max-frame*.)

Commands maximize-frame and restore-frame are general, and can act like the horizontal and vertical commands by giving them a prefix arg: negative for horizontally, non-negative for vertically.

like image 135
Drew Avatar answered Feb 04 '26 16:02

Drew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!