emacs zoom in/zoom out

Emacs

Emacs Problem Overview


Is there a way to zoom in and out (dynamically change the font size, quite smoothly) on emacs?

Emacs Solutions


Solution 1 - Emacs

Try C-x C-+ and C-x C--; that is, Control-x Control-Minus/Control-Plus.

After one combination (C-x C-+ or C-x C--), successives + or - increase or decrease the text scale without typing C-x C- again.

Addition by sawa

I looked up the function that was assigned to the keys mentioned, and found out that they are text-scale-increase and text-scale-decrease. I added the following to my configuration file so that I can do Ctrl+Scroll to zoom in/out. It is useful.

(global-set-key [C-mouse-4] 'text-scale-increase)
(global-set-key [C-mouse-5] 'text-scale-decrease)

Solution 2 - Emacs

The -very nice- answer of user173973 is binding the functions to non-generic mouse events. That is to say that for example on my windows system, the binding command is not valid.

To use it on windows (or probably anywhere) you can use these generic bindings :

(global-set-key [C-mouse-wheel-up-event]  'text-scale-increase)
(global-set-key  [C-mouse-wheel-down-event] 'text-scale-decrease)

Solution 3 - Emacs

This config worked for me:

(global-set-key [C-wheel-up] 'text-scale-increase)
(global-set-key [C-wheel-down] 'text-scale-decrease)

Solution 4 - Emacs

All windows

You'll often want to change your font size because you're showing something to others. Then you likely want all windows to zoom in (including mode-line). For this, default-text-scale is great.

I bind it as such:

(key-seq-define-global "q-" 'default-text-scale-decrease)
(key-seq-define-global "q+" 'default-text-scale-increase)

(global-set-key (kbd "C-M-_") 'default-text-scale-decrease)
(global-set-key (kbd "C-M-+") 'default-text-scale-increase)

Quick single window, and back

For a really quick heavy (16x) zoom-in, you can use: C-u C-u C-x C-+

For going to single-window mode, say for a org presentation: C-x 1

Then you can undo the single-window and return to whatever layout you had before with winner-undo: C-c <left>

Whole desktop

Relatedly, for sharing over a video call, it might be easiest to just change (lower) your desktop resolution. On linux, I pop up arandr for this before starting a sharing session.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsawaView Question on Stackoverflow
Solution 1 - Emacsuser173973View Answer on Stackoverflow
Solution 2 - EmacsPeterView Answer on Stackoverflow
Solution 3 - EmacsStacksysView Answer on Stackoverflow
Solution 4 - EmacsMicah ElliottView Answer on Stackoverflow