Print to a Postscript file
Talk0
1,599pages on
this wiki
this wiki
Recently created tip
We have not yet decided whether to keep this tip as its own page or merge it somewhere else. If you have a suggestion on the tip content, please edit this page or add your comments below (do not use the discussion page).
created November 11, 2008 · complexity basic · author Sightless · version 7.0
If you want to be able to print to printer and file, place this snippet in your vimrc:
let &printexpr="(v:cmdarg=='' ? ".
\"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice)".
\". ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error".
\" : system('mv '.v:fname_in.' '.v:cmdarg) + v:shell_error)"
Then you can print to file by issuing:
:hardcopy filename.ps
or to printer by just issuing:
:hardcopy
Comments
So far this could be considered a bit insecure, as the filename isn't escaped at all. Probably fnameescape or something like that should be used.