mike
mike

Reputation: 219

split emacs window horizontally and keep each at [80] characters

When I run C-x 3, I'd like to have each resulting emacs window be 80 characters wide (my default), making the total emacs frame 80 characters wider. The default behavior is to split the window into two smaller windows.

I'm using the emacs terminology where a "frame" is what you typically refer to as a "window" in a GUI.

Thanks!

Upvotes: 1

Views: 617

Answers (1)

BRPocock
BRPocock

Reputation: 13934

You might want to do something like

 (defun layout-for-cobol ()
   "Lay out the frame as two 80-column windows across"
   (interactive)
   (when window-system
     (require 'frame-cmds)
     (set-frame-width (selected-frame) 160)
     (with-selected-window (get-mru-window)
       (delete-other-windows)
       (split-window-right 80))))

frame-cmds.el can be found at http://www.emacswiki.org/cgi-bin/wiki/frame-cmds.el

You could either call that with M-x layout-for-cobol (or pick a nicer name ☺) or bind it with (when window-system (global-set-key (kbd "C-x 3") 'layout-for-cobol)) in your .emacs file.

(The (when window-system …) forms are to suppress error messages when you try to resize a terminal-mode Emacs.)

Upvotes: 4

Related Questions