Emacs: Set Default Window (frame) Size

By Xah Lee. Date: . Last updated: .

Set Default Window 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")
              ;;
              ))

      (setq default-frame-alist
            '(
              (tool-bar-lines . 0)
              (width . 106)
              (height . 60)
              (background-color . "honeydew")
              ;;
              )))
  (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.

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

Emacs Customization

  1. How to Set Emacs's User Interface
  2. Emacs: How to Install Packages Using ELPA, MELPA
  3. How to Install Emacs Package Manually
  4. Emacs: How to Define Keys
  5. Emacs: M-x customize Tutorial
  6. Emacs: Set File to Open in a Major Mode
  7. Emacs: Organize Init File
  8. Emacs: Byte Compile Elisp Files
  9. Emacs: What's Hook?
  10. Emacs: Set Environment Variables within Emacs
  11. Elisp: Determine OS, Emacs Version, Machine Host Name
  12. Elisp: Check If a {function, variable, feature} is Defined/Loaded
  13. Emacs: Set Default Window (frame) Size
  14. Emacs: Font Setup
  15. Emacs: Set Color Theme
  16. Emacs: Save Cursor Position
  17. Emacs: Turn Off Auto Backup; Set Backups into a Directory; How to Delete Backup Files
  18. Emacs: Stop Cursor Going into Minibuffer Prompt
Like my tutorial? Put $5 at patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs