Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIAi2 WildChat-4.8M (AI2)

How to change font height in emacs?

  1. User

    User: How to change font height in emacs? Assistant: ToTo change the font size (height) in Emacs, you have several methods depending on whether you want to do it temporarily, permanently, or via the GUI.

    Temporarily Change Font Height (Zoom In/Out)

    You can adjust the font size in the current Emacs session using built-in commands:

    • Increase font size (text-scale-increase):
      C-x C-+ (press Ctrl+x, then Ctrl+Shift+=) or
      M-x text-scale-increase and then enter a number (positive to increase, negative to decrease).

    • Decrease font size (text-scale-decrease):
      C-x C-- (press Ctrl+x, then Ctrl+-) or
      M-x text-scale-decrease

    • Reset font size to default:
      C-x C-0

    This changes the font size only for the current buffer.


    Permanently Change Font Height (Font Size) via Init File

    If you want to set a specific font size every time Emacs starts, you can customize the font in your Emacs configuration file (~/.emacs or ~/.emacs.d/init.el).

    Here’s an example to set the font size using the font spec or the simpler string font name syntax:

    ;; Set font with size 14
    (set-face-attribute 'default nil :height 140)
    

    The :height value is in 1/10 pt, so 140 means 14 pt.

    Alternatively, set the font family and size explicitly:

    (set-face-attribute 'default nil :font "DejaVu Sans Mono-14")
    

    Replace "DejaVu Sans Mono" with your desired font family and 14 with your desired font size.


    Changing Font via the M-x set-frame-font Command

    You can also change the font at runtime via:

    M-x set-frame-font RET DejaVu Sans Mono-14 RET
    

    This will change the font for the current frame.


    Summary

    • Temporary zoom: C-x C-+ / C-x C--
    • Permanent font size change: add (set-face-attribute 'default nil :height 140) to your init file
    • Change font at runtime: M-x set-frame-font

    If you want me to provide instructions specific to your operating system or Emacs version, please let me know! User: I mean how to change padding between lines? Is there some variable? Now lines are to close to each other Assistant:

  2. Assistant

    Ah, I see! You want to adjust the line spacing (the vertical padding between lines) in Emacs.

    Emacs controls the spacing between lines using the variable:

    line-spacing
    

    How to change line spacing (add padding between lines)

    • Set line spacing interactively (for the current buffer):
    (setq line-spacing 5)
    
    • line-spacing value is in pixels (or a float) defining extra space between lines.

    • For example:

    (setq line-spacing 0.2)
    

    adds a little extra space, while

    (setq line-spacing 5)
    

    adds more padding.


    How to apply globally (for all buffers)

    Add this line to your Emacs init file (~/.emacs or ~/.emacs.d/init.el):

    (setq-default line-spacing 5)
    

    This will set the default line spacing for all buffers.


    Alternative: Set line spacing only for specific modes or buffers

    You can add a hook, for example for prog-mode buffers only:

    (add-hook 'prog-mode-hook (lambda () (setq line-spacing 5)))
    

    Summary

    • Increase vertical space between lines with:

      (setq-default line-spacing 5)
      
    • Decrease or reset to no extra padding:

      (setq-default line-spacing 0)
      

    Try tweaking the number until you find comfortable spacing!

    If you want to see the effect immediately, evaluate the expression (e.g., with M-:):

    (setq line-spacing 5)
    

    Let me know if you want me to provide instructions for specific modes or more advanced styling!