I find myself consistently zooming out (C-x C--) in every buffer that I am using in order to see more lines of code that I'm working on.

Is there a way to set the zoom level in my .emacs, not interactively? Or should I look into setting the fontsize? I've been using the zoom, because it's been the easiest/quickest solution, but I'd rather find a more permanent solution. Are there disadvantages or advantages to using one versus the other? I am unclear on the differences.

  • 1
    How about?: (face-remap-add-relative 'default '((:height 300))) to blow it up; and (face-remap-add-relative 'default '((:height 120))) to shrink it? You can change the height to your liking. You can turn those into interactive functions and map them to your favorite keyboard shortcuts. To try them out, paste them into your *Scratch* buffer and place the cursor at the end of a code snippet and type C-x C-e – lawlist Mar 31 '15 at 23:45
  • 3
    If you're zooming out in virtually every buffer you use, why not just set the font size to be smaller? See this S.O. thread on exactly that issue. – Dan Apr 1 '15 at 0:26
  • @Dan: If the question is not about zooming, but is, in fact, about how to set the default font size, then it should perhaps be closed as a duplicate of the question you cite. It sounds like the OP is maybe unsure what s?he wants in this regard: set the font size or zoom. – Drew Apr 1 '15 at 2:05
  • @Drew: agreed. OP: are you looking to set the font size or zoom? – Dan Apr 1 '15 at 3:07
  • 1
    My answer would be: In that case, see the Emacs Wiki page I cited in my answer. It covers everything about setting fonts and font sizes, both interactively (e.g. zooming) and in init files (setting defaults). It is the place to start (and probably the place to end). – Drew Apr 1 '15 at 15:28
up vote 8 down vote accepted

Yes. What you want is to zoom (the font size for) a frame, regardless of which buffers are displayed there.

See library zoom-frm.el, and these descriptions of zooming a frame and zooming a buffer.

See, in particular, command zoom-in/out, which does both. It is bound by default to the keys normally bound to just buffer zooming: C-x C-+, C-x C--, C-x C-0, and C-x C-=. You can also bind commands zoom-in and zoom-out to mouse-wheel rotations. Using C-u with any of these commands toggles between frame zooming and buffer zooming.

Besides interactively zooming frames or buffers, you can of course set the default font size you want for all frames.

The same Emacs-Wiki page has more info about setting fonts and font sizes.


Update after you decided that you want to set the default font size

The answer is in the last line I wrote above: See section Globally Change the Default Font on the Emacs Wiki Set Fonts page. It tells you how to set the default font. (It also tells you how to zoom font sizes interactively.)

Here is that information in a nutshell - put this in your init file:

(add-to-list 'default-frame-alist '(font . FONT ))
(set-face-attribute 'default t :font FONT )

But do read the entire section of that page, as it tells you more, including how to set the default font using .Xresources and the Emacs daemon. An example of a line suitable for ~/.Xresources for setting the default font size is:

Emacs.default.attributeHeight: 94
  • I read in the documentation that the zoom-frm.el had the ability to save the customizations, although it seems a bit confusing. (I haven't done much with the customize interface, preferring to set things in the init file, instead) I will give it a try. – aepound Apr 1 '15 at 14:12
  • Yes, the commentary of file zoom-frm.el tells you how to save font-change customizations, including how to do so without using the Customize UI. FWIW, I recommend that people do use Customize, but that use a separate custom-file (see that variable) instead of letting Customize write code to their init file. – Drew Apr 1 '15 at 15:39

If you want to use a GUI font picker with previews and all, you may use M-x menu-set-font

Emacs pick a font

  • 1
    Thanks, this should be the only recommended answer, here, on the wiki page, on the Aquamacs home page! – agam Feb 28 at 18:00

I'm using this for zooming Emacs-wide (not just the current buffer):

;; http://blog.vivekhaldar.com/post/4809065853/dotemacs-extract-interactively-change-font-size
(defun my/zoom-in ()
  "Increase font size by 10 points"
  (interactive)
  (set-face-attribute 'default nil
                      :height
                      (+ (face-attribute 'default :height)
                         10)))

(defun my/zoom-out ()
  "Decrease font size by 10 points"
  (interactive)
  (set-face-attribute 'default nil
                      :height
                      (- (face-attribute 'default :height)
                         10)))

;; change font size, interactively
(global-set-key (kbd "C->") 'my/zoom-in)
(global-set-key (kbd "C-<") 'my/zoom-out)

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.