Emacs: Set Default Window Size

By Xah Lee. Date: . Last updated: .

Set Default Window (Emacs Frame) Size

Put this in your emacs init file:

(if (display-graphic-p)
      (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))))
    (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

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys


ELisp Examples

ELisp Write Major Mode

Emacs Init

Init Basics


text editing