Sublime Forum

Preview and Print


Here’s a plugin for print preview in Sublime Test 3. (In addition to previewing, it can apply margins, fonts and other formatting to printed text, make use of a standard printer dialog box, or send text directly to a printer without preview or formatting.)

So far this is mostly a linux plugin - I haven’t tested it under Windows yet. I am hoping first that someone will volunteer to test it further under linux and share feedback.

Depending on how you set up the configuration options, the plugin can perform a variety of formatting/viewing/printing tasks. Each of these tasks relies on an external program, as described below:

  • Send unformatted text directly to the printer: Requires lpr.
  • Display a standard dialog box for choosing a printer, duplex vs single sided, sheets per page, etc: Requires gtklp or xpp.
  • Full page preview + printer dialog. Evince or okular. (Xpdf and acroread can also work for markdown files.)
  • Applying formating to text documents and syntax highlighting to (printed) code: Needs enscript to create a temporary formatted postscript version of your document.
  • Print/preview fully formatted markdown documents: Pandoc with latex, context or wkhtmltopdf. A temporary copy of the document is converted to pdf.

If you have selected one or more blocks of text when PreviewAndPrint is triggered, only the selected blocks of text will be previewed or printed. (You can change this behavior in the user configuration file.) If you have a working installation of pandoc and latex, you can preview (all of or selections from) latex formatted markdown files. Using the configuration file’s “postscript options,” you can set fonts, margins, etc for printed plain text documents.

A fuller explanation is in the readme file.

This plugin isn’t in package control. Download the zipped files from here. Unzip into a directory under ~/.config/sublime-text-3/Packages/.

Feedback is much appreciated.



I never print stuff from Sublime Text, but for the installation part, there’s a less hacky way:

  1. Open up the command palette (ctrl+shift+p), and find Package Control: Add Repository. Then enter the URL of this repo: in the input field.
  2. Open up the command palette again and find Package Control: Install Package, and just search for SublimePreviewAndPrint. (just a normal install)

I just hope this thread won’t reload the printer lovers :smile:



Thanks for the installation tips!

I don’t want to relitigate the whole ‘Sublime’s no good cause it can’t print’ thing either. (So maybe I shouldn’t say the following:) I don’t doubt that people have a legitimate need to print - that’s why I wrote this plugin. However I’m struck by the degree to which some feel aggrieved by the issue. Why get upset when Sublime already has the ability to print through one of several nice plugins? ExportHTML works well. The SublimePrint plugin does a good job with prose/text and if you add a “highlight” value to its configuration file then you can also print color highlighted code. If you want to get sophisticated, you can use markdown syntax with latex formatting, convert to pdf with the Pandoc plugin and then preview and print from evince. The developers of Sublime have obviously worked hard to make it extensible, and this effort pays off in a very wide range of useful plugins. Why then the big debate about printing in particular? If you need to print, figure it out and print.



@daneli, if you add in README.MD screenshots/screencasts, your plugin will be used more users =) . Thanks.



Good idea. I will add some to the readme and here as well.

Here’s an example of enscript’s code highlighting, previewed in okular, and ready to print:

Markdown (+ latex) previewed in evince, choosing printer options:

No preview, using gtklp to select printer options:



Sorry for the trouble - and the uninformative error message.

Can you check the following fields in your configuration file:




You will find these fields under Preferences -> Package Settings -> PreviewAndPrint -> Settings-Default. (Or in Settings-User if you have overwritten the default.)

What program is specified for the previewer? And for the converter? Are the specified preview and converter programs installed on your system and also available on your path?



Nothing there for me. What can I do?

Is there any reason why this editor is so different and comes with no default print/printpreview function like probably all the other text editor?

Thank you very much.



Hi. Is PreviewAnd Print not showing up at all under Preferences -> Package Settings? If so, I think that means the plugin hasn’t been installed. Can you tell me the OS (& version) you’re running?

As to your second question: There’s been lots of discussion about that on this forum and probably everything has been said that could be said. I don’t like it when people are told “use the search function” but in this case it probably makes sense to read through some of the old discussions to get a feel for the debate.

1 Like



Thanks for this Plugin.
Does the plugin run on macOS? What do you have to set?

If I currently click on “File”> “PreviewAndPrint”, it just doesn’t happen.




For the simple reason that I never coinsidered looking at Plugins to supply a fundamental feature of a code editor. It is like having to add a plugin to have a Delete key.



Less Hacky?

( ctrl+shift+p ) brings up a Widows Print dialogue.