VIM contains a 'set guifont' option to change the font. Neovim does not support this option, so I am wondering if it's possible to change the font Neovim uses in the Terminal?
-
A possible workaround: If your terminal supports it, you may be able to pass a config file or font as a CLI option on launching a new terminal. For example with Alacritty, something like `function vim() { alacritty -o font.normal.family="Fira Code" -e nvim "$@" }`. That way at least the change remains local to Neovim. – wardw Jan 26 '23 at 15:31
9 Answers
This is not for a terminal, but still it might be useful to someone.
For Neovim-Qt GUI client, you can change the font by Ctrl + mouse scroll if you put the following to ginit.vim
:
let s:fontsize = 12
function! AdjustFontSize(amount)
let s:fontsize = s:fontsize+a:amount
:execute "GuiFont! Consolas:h" . s:fontsize
endfunction
noremap <C-ScrollWheelUp> :call AdjustFontSize(1)<CR>
noremap <C-ScrollWheelDown> :call AdjustFontSize(-1)<CR>
inoremap <C-ScrollWheelUp> <Esc>:call AdjustFontSize(1)<CR>a
inoremap <C-ScrollWheelDown> <Esc>:call AdjustFontSize(-1)<CR>a
For those who prefer using keyboard, there is a nice way to use numpad's +
(kPlus
) and -
(kMinus
)
" In normal mode, pressing numpad's+ increases the font
noremap <kPlus> :call AdjustFontSize(1)<CR>
noremap <kMinus> :call AdjustFontSize(-1)<CR>
" In insert mode, pressing ctrl + numpad's+ increases the font
inoremap <C-kPlus> <Esc>:call AdjustFontSize(1)<CR>a
inoremap <C-kMinus> <Esc>:call AdjustFontSize(-1)<CR>a
Obviously you can replace Consolas
with the font you prefer.

- 1,051
- 13
- 17
-
there was no Consolas font on my system (Xubuntu 18.04) but this worked `:execute "GuiFont! DejaVu Sans Mono:h" . s:fontsize` – askonecki Mar 05 '19 at 10:51
Change the font in your terminal emulator's preferences. Terminal programs generally can't set their own fonts. Only GUI clients like Gvim or macvim use the set guifont
option.

- 2,324
- 24
- 26
How to change the font depends on how you are currently using Neovim:
For terminal Neovim
If you use Neovim in a terminal, to change the font neovim used, you need to change the font your terminal uses. Check your terminal manual on how to change font style and font size, etc.
For Neovim GUI client
For Neovim GUI client, you need to set the font in the file ginit.vim
. ginit.vim
is located in the same folder as init.vim
or init.lua
[^1]. Different GUI clients have different command for setting the font you use and font size. An incomplete list of GUI clients I have tried:
- nvim-qt: Use the comamnd
GuiFont
insideginit.vim
to change font, for example,GuiFont Hack:h12
(suppose you have installed font Hack). - fvim: fvim is another Neovim GUI client. You can use
set guifont=Hack:12
insideginit.vim
to set the font that fvim uses.
[^1]: Inside Neovim, run command :echo stdpath('config')
to show the neovim configuration directory.

- 24,001
- 18
- 134
- 273
-
It seems to me that `GuiFont` is what should be used. However nvim-qt v0.8.2 on Windows changes the font after restarting the application. I posted my workaround as an answer below. – Martin Feb 17 '23 at 13:07
I use Neovim-qt version on my Ubuntu18.04. But I use the same config file for my vim.
After trial-and-error, I found the way to change neovim font to FiraCode Monospace. Although you could type the command :Guifont Fira Mono:h12
inside GUI to change the currently used font, it works only once. After you close the GUI, need to set up the font again. : (
Or you need another config file ginit.vim
to set up GUI-related things. The same problem of setting up font for GUI, just write GuiFont Fira Mono:h12
in ginit.vim
.

- 1,950
- 17
- 14
Apart from the answers in this question, the reason many scripts/plugins that works for vim/Gvim but not NeoVim (qt) is that in NeoVim, the font is defined by Guifont
instead of guifont
.

- 277
- 2
- 13
i used neovim in wsl so if you asking in wsl i could help. change the terminal font you will able to do that at list in wsl.
so download and install font of your need and cmd > properties > font and choese your font
Adding to the other great answers: if you prefer to have something in lua that does all that, you could use size-matters.nvim. It's little plugin I had fun writing for this purpose.

- 370
- 2
- 10
Using neovim on Windows (nvim-qt, NVIM v0.8.2), my font settings in init.vim
not in effect after restarting the application.
As a workaround I set two different font settings in init.vim
e.g.
set guifont=Source\ Code\ Pro\:h13
set guifont=Source\ Code\ Pro\:h14
This seems to force an explicit font change every time the application is started and yields the desired result: The second font that is set.
On Windows and Mac there's a graphical font picker :set guifont=*
Once a font is set, use :set guifont?
to find out it's name. Mind escaping spaces with \
as in the examples.
Note the difference in specifying font sizes on Windows and Linux:
Linux: set guifont=Source\ Code\ Pro\ 14
Windows: set guifont=Source\ Code\ Pro\:h14

- 659
- 7
- 14
At first, if you are using the 'text-mode' nvim, just setup by your terminal(eg. putty, rxvt,...)
For nvim-qt, fnvim (GUI version nvim), here is the solution
- Choose a font by
:set guifont=*
command. - Display the correct font name by
:set guifont?
command, remember when writing into config file, thespace
character should proper escape later. (For example the font name isJetBrainsMono NFM:h10
) - Find your
config_path
by:echo stdpath('config')
, for linux, it is often~/.config
, for Windows it is often$env:LOCALAPPDATA
- Setup your config file, for example, mine lazyvim setup, nvim-qt version 0.2.16.1 on Windows. The config file can be one of these files
- <config_path>/nvim/ginit.lua
- <config_path>/init.lua
- <config_path>/nvim/lua/config/options.lua (I prefer this)
edit the proper config file as
if vim.fn.has("gui_running") then
-- vim.cmd("set guifont=JetBrainsMono\\ NFM:h10")
vim.opt.guifont = "JetBrainsMono\\ NFM:h10"
end

- 15,050
- 18
- 63
- 96