I would like to be able to print in other than Courier font using the :ha command.

Investigating more closely, I found that it is documented that the Courier font is always used:

- 'printfont' - The font name is ignored (the Courier family is always used -
  it should be available on all PostScript printers) but the font size is

— From :help postscript-printing

However, there must be some workaround, perhaps using an external tool.

I would like to keep my Vim syntax highlighting in the printout, which rules out just opening the file in TextEdit (or TextWrangler) for printing.

I'm using MacVim snapshot 73, which is Vim 7.4.258.

How can I print a file to PDF using Vim's syntax highlighting but an alternate font?

2 Answers 2


Instead of printing from Vim, you could instead generate an HTML file using :TOhtml. Then you can use CSS to set the font used for the HTML and print that.

  • 1
    This answer is amazing. Been using vi since the 80s, and vim since it came out, never knew about this. Even carries utf-8 content over to the html.
    – erco
    Commented Jan 6, 2023 at 7:27

I don't know when it changed, but now it's possible.

For example:

:set printfont=Fira_Code:h12

do the job.
I'm using Vim 9 on Windows.

(P.S. I will try with MacVim in a few days and I'll update this answer.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.