It’s a continues struggle to become efficient in using VIM, especially if one ventures outside of what one regularly needs to do. It’s well worth it though since it might be the last text editor that you’ll ever need to master.
I was faced with having to produce pdf with selected code snippets.
Here is the fastest approach… be warned this example is for macs but I am sure it can work in other Li/Unix environments as well.
Install CUPS PDF and setup a virtual printer as is described on that page. Make sure that it’s the default printer after you have set it up.
The command to print in vim is :ha which is a short for :hardcopy this will spool the whole file to the print que for that driver and ultimately drop a pdf in cups-pdf folder on your desktop. To print out a selection simply highlight some text before issuing :ha command. I needed the line-numers of the code samples and this can be achieved by setting printoptions.
set printoptions=number:y
Now to be a complete terminal snob you should check out pdftk
Leave a Reply