Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to print to file from Vim

📅 2014-Oct-12 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ print, vim ⬩ 📚 Archive

Printing from Vim is not like any other application since it has both console (Vim) and desktop (GVim) versions running off the same backend. On Linux, it does not show a Print Dialog, where I can pick the printer and other print options like number of pages per side, orientation and duplex. So, I print to a PDF file, open it in a PDF viewer and print from there.

To print to a PDF file from Vim:

:hardcopy > out.pdf

To print to a PS file from Vim:

:hardcopy > out.ps

Tried with: Vim 7.4 and Ubuntu 14.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧