Export Document in vim to PDF (with syntax highlight)

I use vim with syntax highlight as my primary editor. I was writing some ruby for Linux class. I wanted to hand in my assignment as PDF with syntax highlight. So I found google around and found this trick:

First off, we have vim with :syntax on

Next,  we print it to postscript (.ps) with the command:

:hardcopy >/tmp/filename.ps

vimsyntax

next we cd to /tmp and convert the .ps to pdf

:~$ cd /tmp
:/tmp$ ps2pdf example.ps
:/tmp$ ls *.pdf
example.pdf

the PDF looks like this: example pdf

 

//M00kaw

2 Responses to “Export Document in vim to PDF (with syntax highlight)”


Comments are currently closed.