Emacs: Changing the font size on the fly
| emacsI have a tiny laptop: 8.9″ diagonally. With a 1024×768 pixels screen
resolution, things can get *pretty* small. The following functions use
the gnome-terminal-style shortcuts (Ctrl-plus, Ctrl-minus) to change
the font size without the mouse:
(defun sacha/increase-font-size () (interactive) (set-face-attribute 'default nil :height (ceiling (* 1.10 (face-attribute 'default :height))))) (defun sacha/decrease-font-size () (interactive) (set-face-attribute 'default nil :height (floor (* 0.9 (face-attribute 'default :height))))) (global-set-key (kbd "C-+") 'sacha/increase-font-size) (global-set-key (kbd "C--") 'sacha/decrease-font-size)
2 comments
Alex
2010-08-06T16:30:43ZDid not work for me. I copied the code in my .emacs file. Did I do anything wrong? Any suggestion?
I have to say that I rather new to linux.
/Alex
Alex
2010-08-06T16:49:31ZCorrection:
It works now but not with the plus and minus that are located in the right most part of the keyboard (next to numbers). Those were the one I was initially trying with.
There is also one small issue. When I use ctrl-plus, the font size increases step by step (total 3 steps). However, when I use ctrl-minus, it shrinks the font to the smallest possible directly. A minor issue but just thougth to share it.
/Alex