216

Sublime Text 2 seems like a great editor. I just started using it a week ago in eval mode and it doesn't seem to have any printing functionality. This seems preposterous to me, but I can't find it anywhere.

Is this a feature unlocked after purchase? I see no mention of that on the company website.

Can anyone help?

2
  • If you need the line numbers matching script, then the suggestions of the others are the standard workarounds. I do not normally need line numbers when printing, so I have set up a blank LaTeX formatted document that I use when printing from and saving to *.pdf. I have also set up an insert file here plugin so that I don't have to block and copy -- a surrounding snippet would also work. The LaTeX option is one that I rarely ever see mentioned. There is a very nice plugin for LaTeX, and I've also created some modifications to deal with cleanup issues. There is a learning curve though.
    – lawlist
    Commented Apr 15, 2013 at 5:35
  • 19
    I've been shaking my head in disbelief after I paid my registration fee, when I found out there was no support for printing..... how can anyone dream up a text editor and not provide any printing?!?!?!? C'mon - this is totally utterly brain-dead!
    – marc_s
    Commented Jan 6, 2015 at 14:07

10 Answers 10

118

There is also the Simple Print package, which uses enscript to do the actual printing.

Similar to kenorb's answer, open the palette (ctrl/cmd+shift+p), "Install package", "Simple Print Function"

you MUST install enscript and here is how:

https://github.com/svenax/SublimePrint

5
  • 9
    This should be the correct answer by now, since it makes the workaround with SublimeHighlight obsolete Commented Nov 12, 2013 at 11:16
  • I don't know if it will help as I am not using windows but there is a version of enscript for windows: gnuwin32.sourceforge.net/packages/enscript.htm - however this will probably not help if the package uses lpstat to query the printers first
    – marsbard
    Commented May 19, 2015 at 8:56
  • 1
    Actually, see the third comment on this issue for the windows workaround @GiorgioVespucci github.com/svenax/SublimePrint/issues/5
    – marsbard
    Commented May 19, 2015 at 8:57
  • 1
    Also, to make things clear: you'll need to have package control installed. The Printing function appears in the menu of sublime text. Commented Mar 7, 2016 at 8:58
  • 2
    It didn't work for me yet. I'm on mac 10.10. For now I used my old reliable Tex-edit Plus. In Sublime, I did; 1.installed enscript on my mac with "brew install enscript"; 2.Downloaded and put the PackageControl file into ~/Library/Application\ Support/Sublime\ Text\ 3/Installed\ Packages ; 3.Used Tools/Command palatte / Install package / Simple print; 4.The menus show up but it doesn't work. Commented Mar 17, 2016 at 21:25
86

This isn't supported yet. You can use plugins to export the text into HTML or RTF first, and then you can print it out, if you want.

Here is for example the SublimeHighlight plugin which you can use for exporting.

18
  • 81
    Thanks. But really? in version 2 of a text editor there's no print functionality? Any idea why not? Commented Apr 14, 2013 at 22:06
  • 3
    I think it would be a reasonable feature, almost every text editors and IDEs support printing. But there are a lot of more popular feature requests on the todo list, so I accept why it hasn't implemented yet.
    – Zsolt
    Commented Apr 14, 2013 at 22:22
  • 262
    A software which costs 70$ should support printing.
    – Oliver
    Commented Jun 9, 2013 at 16:13
  • 22
    @BSeven It turns out that ST2 is useful for text editing tasks beyond coding. And while it's awesome that "people" only do a tiny amount of printing, other different people actually print documents fairly frequently, for a variety of reasons. Commented Sep 24, 2013 at 17:34
  • 14
    I was shocked to find this. Heck notepad.exe supports simple printing, When I have to copy anything to have notepad print it, fail++, even if everything else is nice. Commented Nov 10, 2013 at 7:09
33

TL;DR Use Cmd/Ctrl+Shift+P then Package Control: Install Package, then Print to HTML and install it. Use Alt+Shift+P to print.

My favorite tool for printing from Sublime Text is Print to HTML package. You can "print" a selection or a whole file - via the web browser.

Usage

  1. Make a selection (or none for the whole file)
  2. Press Alt+Shift+P OR Shift+Command+P and type in "Print to HTML".

This opens your browser print dialog (Chrome for me) with the selected text neatly in the print dialog window and syntax highlighting intact. There you can choose a printer or export to PDF, and print.

Setup

Install the "Print to HTML" package using the package manager.

  1. Ctrl + Shift + P => Gives a list of commands.
  2. Find the package manager by typing "install"
  3. You see a few choices. Select "Package Control: Install Package"
  4. This opens a list of packages. Type "print to"
  5. One of the choices should be "Print to HTML". Select that, and it is being installed.
  6. You can use the "print to html" now by a keyboard shortcut Alt+Shift+P
2
  • 3
    Thank you. FWIW FYI it also works with Sublime Text 3
    – tags
    Commented Jun 16, 2020 at 11:31
  • 1
    Kudos! Worked like a charm
    – iaforek
    Commented May 20, 2021 at 9:38
26

UPDATE 2016: Somewhere between July 2015 and January 2016 the printing feature request that I wrote about in 2014 was removed. The original answer is below, with the relevant links changed to the latest working versions in the Web Archive:

Original 2014 Answer

Printing in Sublime Text is a feature that has been requested for about 4 years (as of 2014), with 1600+ supporting votes and 160+ comments in the discussion below. For something around 6000 feature requests this is in the top 5.

See the original, still open, feature request:

enter image description here

Judging from the feature request (still open with no official answer) it seems unlikely that printing will ever get implemented in version 3 (as others have suggested) or in any version at all.

The discussion below this feature request may give some insight on why printing is not supported and whether or not it has a chance to get supported in the future.

Maybe if more people vote or comment it will change in the future. (See Update 2016 below for an up-to-date list of feature requests)

Some workarounds were suggested, the most popular advices were to use some other editor for printing (eg. Brackets, Atom, gedit, Notepad++) or to use some 3rd party plugins that reportedly don't work well or at all.

In general there is a strong opposition to adding printing as a native feature of Sublime Text which for such a universal functionality among text editors seems surprising, but may nevertheless shed some light on this issue.

Meanwhile, there are many free editors that can print (in fact I cannot think of a single one that couldn't) so it is easy to use some other editor whenever a need for printing arises.

Update 2016

Since the feature request described above was removed (please comment if anyone knows why) here is an up-to-date list of some other places to find more info about printing in Sublime Text:

Since the original feature request #25170 was removed, you should vote and comment in the other feature requests about printing instead.

11
  1. Install the Package Control first and restart your editor. See: How to install plugins to Sublime Text 2 editor?
  2. Install Highlight plugin.
    1. Open the pallete, press ctrl+shift+p (Win, Linux) or cmd+shift+p (OS X).
    2. Type and confirm: Install Package
    3. Type and confirm: Highlight or Print

Also see related printing forum topic: Printing from sublime

0
4

I like ExportHTML, which exports to html, opens it up in your browser, and optionally opens the system print dialog. Looks good, too. Not a perfect replacement for native printing, but pretty close.

1

Sorry to say that there is no print function in sublimetext2, may be 3 will fix this?

Anyway there are a few plugins that are floating about, the most helpful for you might be print-to-HTML https://github.com/joelpt/sublimetext-print-to-html .

1
  • I've tried PrintToHTML, and it doesn't really work well with code: code indenting is not respected as it uses a variable width font, and unless all of the indenting in your code consists of all tabs or all spaces, code blocks will just wander all over the page. It may be possible to add some css to the generated XML specifying a mono-spaced font, but this one issue was enough to alienate me from Sublime. As pretty as it is, people have been asking for native printing for three years, and the developer has, for his own ideological reasons, I suppose, chosen to ignore the requests.
    – Curt
    Commented Jun 16, 2014 at 3:14
1

One way to print your code is to push it to an online version control system like Github or Bitbucket. In your browser, navigate to the file and print it.

Doing it this way, you'll get syntax highlighting and version control.

0

Still no print no native print function, but outside the installing the suggested package, you can go the autohotkey way, as the that app can actually help you run macros for other stuff as well. So you can do something like create a macro that with one click does:

  1. Select all the text
  2. Copies all the text
  3. Opens your other edit of choice
  4. pastes text
  5. Prints text

No the most glamorous of options but could also work if the receiving app has can accept code-formatting.

0

A workaround without installing any package :

  1. Let's say you have a document like this
Paragraph1
Paragraph2
Paragraph3
2. Just Add html and pre tag before and after your document like this

<html>
<pre>

Paragraph1
Paragraph2
Paragraph3

</pre>
</html>

  1. Save this with .html extension
  2. Now Open it in browser
  3. Now you can print it using Ctrl+P or going to Print option in browser.

Not the answer you're looking for? Browse other questions tagged or ask your own question.