How to increase font size in Vim editor?
I write C programs in Vim; the font size in it is very small.
Is there any option to increase the font size in Vim?
Solution 1:
This may not be an ideal solution but it works for me.
Just zoom in on your terminal with Ctrl+Shift++.
Zoom out with Ctrl+-
Solution 2:
According with http://vim.wikia.com/wiki/Change_font:
Console Vim uses whatever font your console/terminal is using. [...]
When running inside a terminal, Vim can, at most, change the colours (within the limits of the colours supported by the terminal: sometimes bold and unbold black and white, often 8 colours plus bold/unbold foreground only [or seen another way, 8 background and 16 foreground]; on X11 some terminals support up to 256 background and foreground colours; "changing colours" usually also includes the use of reverse-video), and, if the terminal supports them (not all terminals do, and even those which do may support it only with certain fonts), use bold, underline and/or italic.
That being said, if you want to change the font size in Vim editor, you have to change the font size of your terminal. To do this in gnome-terminal go to Edit → Profile Preferences:
Moreover, you can save these preferences in a new terminal profile and when you are start using Vim, use that profile.
Solution 3:
As @Costa said in the comment, you can
- run
:set guifont
to get the current font - for me, that is
Hack 10
- then set the font with a larger size
:set guifont=Hack\ 12
(note the\
to escape the space)
Solution 4:
Ctrl + mouse scroll up
Ctrl + mouse scroll down.
This works for most terminals.
Solution 5:
I use Vim in Xfce4 Terminal. I assigned this script to the keyboard shortcuts ctrl alt + and ctrl alt - which are the usage script-name --in
and script-name --out
respectively.
#!/bin/bash
# Check if Xfce4 Terminal is running. If it is not, exit.
status=$(pgrep xfce4-terminal)
if [ -z "$status" ]; then
notify-send "No Xfce4 Terminal session is open."
exit 1
fi
# 1. Get the full line. 2. Get the entire line minus font size. 3. Get only font size.
line=$(grep "FontName" ~/.config/xfce4/terminal/terminalrc)
font_name=$(echo "$line" | sed s/'\w*$'//)
font_size=$(echo "$line" | grep -oE '[^ ]+$')
# Increase or decrease font size. You might want to change this to increase and decrease by two.
if [ "$1" = "--in" ]; then
new_size=$((font_size + 1))
elif [ "$1" = "--out" ]; then
new_size=$((font_size - 1))
else
notify-send "Argument options: --in --out"
exit 1
fi
# Replace the line with the new font size.
action='s/'$font_name$font_size'/'$font_name$new_size'/'
sed -i "$action" ~/.config/xfce4/terminal/terminalrc
# Show only one notification at a time.
notify_status=$(pgrep xfce4-notifyd)
if [ -n "$notify_status" ]; then
pkill xfce4-notifyd
fi
# Show the new current font being used.
notify-send -t 200 "$new_size pt font"