Tip 1609 Printable Monobook Previous Next

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.

Why not just using the builtin ":hardcopy >"?

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.