1

I know that I can use the GUI to navigate to the panel for setting guifont, and I can also issue :set guifont=*.

Is there a way to list all options as text?

I would like to capture them in a register using :redir @a, then paste them into a buffer and turn each one into a set guifont command:

set guifont=The\ first\ font
set guifont=The\ second\ font
set guifont=The\ third\ font
set guifont=The\ fourth\ font
     ... etc ...

It would them be simple to yank each one into register " and paste them into the command line. Depending on what I see, I can re-order the list from best to last (or best smallest to best biggest). I can retry each one as desired to refine the ordering.

Current work-around

My aim was to identify a series of fonts and sizes to which to map to . My work-around is below. I would still be interested in whether there is a way to render into text all the font names (family, weight, slant, size) in the guifont selection.

I manually transcribed the font family names from the selection list for guifont into a text file, then added the font size and vertical line spacing. Comparably small fonts are:

Comparable small sizes of palatable font families
----------------------
set guifont=Lucida\ Console\ Regular\ 9 linespace=0
set guifont=Monospace\ Regular\ 8 linespace=0
set guifont=Liberation\ Mono\ Regular\ 8 linespace=0
set guifont=DejaVu\ Sans\ Mono\ Book\ 8 linespace=0
set guifont=Consolas\ Regular\ 9 linespace=0

I used the following test text to view the various fonts:

Test text
---------
The quick brown fox jumped over the lazy dogs
The quick brown fox jumped over the lazy dogs
The quick brown fox jumped over the lazy dogs
The quick brown fox jumped over the lazy dogs
The quick brown fox jumped over the lazy dogs
The quick brown fox jumped over the lazy dogs
The quick brown fox jumped over the lazy dogs
The quick brown fox jumped over the lazy dogs

I then replicated each font enough times to perturb the font size through a healthy range of sizes, truncating this range for fonts that I didn't really like:

Step through sizes for each family
----------------------------------
set guifont=Consolas\ Regular\ 9 linespace=0
set guifont=Consolas\ Regular\ 10 linespace=0
set guifont=Consolas\ Regular\ 11 linespace=0
set guifont=Consolas\ Regular\ 12 linespace=0
set guifont=Consolas\ Regular\ 13 linespace=0
set guifont=Consolas\ Regular\ 14 linespace=0
set guifont=Consolas\ Regular\ 15 linespace=0
set guifont=Consolas\ Regular\ 16 linespace=0
set guifont=Consolas\ Regular\ 17 linespace=0

set guifont=DejaVu\ Sans\ Mono\ Book\ 8 linespace=0
set guifont=DejaVu\ Sans\ Mono\ Book\ 9 linespace=0
set guifont=DejaVu\ Sans\ Mono\ Book\ 10 linespace=0
set guifont=DejaVu\ Sans\ Mono\ Book\ 11 linespace=0
set guifont=DejaVu\ Sans\ Mono\ Book\ 12 linespace=0
set guifont=DejaVu\ Sans\ Mono\ Book\ 13 linespace=0
set guifont=DejaVu\ Sans\ Mono\ Book\ 14 linespace=0

set guifont=Inconsolata\ Medium\ 8 linespace=0
set guifont=Inconsolata\ Medium\ 9 linespace=0
set guifont=Inconsolata\ Medium\ 10 linespace=0
set guifont=Inconsolata\ Medium\ 11 linespace=0
set guifont=Inconsolata\ Medium\ 12 linespace=0
set guifont=Inconsolata\ Medium\ 13 linespace=0
set guifont=Inconsolata\ Medium\ 14 linespace=0

set guifont=Liberation\ Mono\ Regular\ 8 linespace=0
set guifont=Liberation\ Mono\ Regular\ 9 linespace=0
set guifont=Liberation\ Mono\ Regular\ 10 linespace=0
set guifont=Liberation\ Mono\ Regular\ 11 linespace=0
set guifont=Liberation\ Mono\ Regular\ 12 linespace=0
set guifont=Liberation\ Mono\ Regular\ 13 linespace=0
set guifont=Liberation\ Mono\ Regular\ 14 linespace=0

setl guifont=Lucida\ Console\ Regular\ 9 linespace=0
setl guifont=Lucida\ Console\ Regular\ 10 linespace=0
setl guifont=Lucida\ Console\ Regular\ 11 linespace=0
setl guifont=Lucida\ Console\ Regular\ 12 linespace=0
setl guifont=Lucida\ Console\ Regular\ 13 linespace=0
setl guifont=Lucida\ Console\ Regular\ 14 linespace=0
setl guifont=Lucida\ Console\ Regular\ 15 linespace=0

set guifont=Monospace\ Regular\ 8 linespace=0
set guifont=Monospace\ Regular\ 9 linespace=0
set guifont=Monospace\ Regular\ 10 linespace=0
set guifont=Monospace\ Regular\ 11 linespace=0
set guifont=Monospace\ Regular\ 12 linespace=0
set guifont=Monospace\ Regular\ 13 linespace=0
set guifont=Monospace\ Regular\ 14 linespace=0

set guifont=Source\ Code\ Pro\ Regular\ 9 linespace=0
set guifont=Source\ Code\ Pro\ Regular\ 10 linespace=0
set guifont=Source\ Code\ Pro\ Regular\ 11 linespace=0

set guifont=Source\ Code\ Pro\ Medium\ 9 linespace=0
set guifont=Source\ Code\ Pro\ Medium\ 10 linespace=0

I liked Lucida Console Regular best through all the sizes, including vertical spacing. So in my vimrc, I created the following mappings for quick font size switching:

    ... snip ...

elseif hostname() ==? "Name_of_laptop"

   map <C-F2> :setl guifont=Lucida\ Console\ Regular\ 7.5 linespace=0<CR>
   map <C-F3> :setl guifont=Lucida\ Console\ Regular\ 8 linespace=0<CR>
   map <C-F4> :setl guifont=Lucida\ Console\ Regular\ 9 linespace=0<CR>
   map <C-F5> :setl guifont=Lucida\ Console\ Regular\ 11 linespace=0<CR>
   map <C-F6> :setl guifont=Lucida\ Console\ Regular\ 12 linespace=0<CR>
   map <C-F7> :setl guifont=Lucida\ Console\ Regular\ 13 linespace=0<CR>
   map <C-F8> :setl guifont=Lucida\ Console\ Regular\ 14 linespace=0<CR>
   map <C-F9> :setl guifont=Lucida\ Console\ Regular\ 15 linespace=0<CR>
   map <C-F10> :setl guifont=Lucida\ Console\ Regular\ 16 linespace=0<CR>
   map <C-F11> :setl guifont=Lucida\ Console\ Regular\ 17 linespace=0<CR>
   map <C-F12> :setl guifont=Lucida\ Console\ Regular\ 18 linespace=0<CR>
2
  • 1
    For the execution part, might be worth temporarily mapping something to :exec getline('.')
    – D. Ben Knoble
    Jan 24 '20 at 14:03
  • Thanks, D. Ben Knoble. Jan 24 '20 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.