Vim Tips Wiki

Print to a Postscript file

Revision as of 10:36, December 20, 2008 by JohnBot (Talk | contribs)

1,616pages on
this wiki

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
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:


or to printer by just issuing:



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.

Around Wikia's network

Random Wiki