Emacs: Set Default Window Size

By Xah Lee. Date: . Last updated: .

Set Default Window (Emacs Frame) Size

Put this in your emacs init.

(if (display-graphic-p)
    (progn
      (setq initial-frame-alist
            '(
              (tool-bar-lines . 0)
              (width . 106) ; chars
              (height . 60) ; lines
              (background-color . "honeydew")
              (left . 50)
              (top . 50)))
      (setq default-frame-alist
            '(
              (tool-bar-lines . 0)
              (width . 106)
              (height . 60)
              (background-color . "honeydew")
              (left . 50)
              (top . 50))))
  (progn
    (setq initial-frame-alist '( (tool-bar-lines . 0)))
    (setq default-frame-alist '( (tool-bar-lines . 0)))))

The display-graphic-p check if emacs is running in graphical environment. (that is, not terminal)

Many settings related to windows size are not relevant if emacs is running in terminal.

initial-frame-alist is a variable that holds a alist of settings for the first window emacs starts with.

default-frame-alist is a variable that holds a alist of any new window.

[see Elisp: Association List]

Alt+x describe-variable to see a variable's values.

(info "(elisp) Frame Parameters")

Background Color for New Window

(setq default-frame-alist
  '((background-color . "cornsilk")))

To see a list of color names emacs support, Alt+x list-colors-display.

Set Default Font

Emacs: Font Setup

Manage Windows Topic

  1. Split Windows
  2. Save Split Windows Configuration
  3. Effective Windows Management
  4. Make Buffer Flow Side-by-Side
  5. Restore Opened Files, Windows Config
  6. Set Default Window Size

Emacs Customization

  1. Emacs init file
  2. Install Packages
  3. Install Package Manually
  4. Define Keys
  5. M-x customize
  6. What's Major Mode?
  7. What's Minor Mode?
  8. Set File to Open in a Major Mode
  9. Organize Init File
  10. Byte Compile Elisp
  11. What's Hook?
  12. Environment Variables in Emacs
  13. Set Default Window Size
  14. Font Setup
  15. Set Color Theme
  16. Turn Off Auto Backup; Set Backups into a Directory; How to Delete Backup Files
  17. Elisp: Determine OS, Emacs Version, Machine Host Name
  18. Elisp: Check If a {function, variable, feature} is Defined/Loaded
Patreon me $5 patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboards for Emacs

If you have a question, put $5 at patreon and message me.