214

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?

John Biddle
  • 2,664
  • 2
  • 15
  • 25
  • 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 Apr 15 '13 at 05: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 Jan 06 '15 at 14:07

10 Answers10

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

grepit
  • 21,260
  • 6
  • 105
  • 81
marsbard
  • 2,168
  • 1
  • 15
  • 16
  • 9
    This should be the correct answer by now, since it makes the workaround with `SublimeHighlight` obsolete – klaffenboeck Nov 12 '13 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: http://gnuwin32.sourceforge.net/packages/enscript.htm - however this will probably not help if the package uses lpstat to query the printers first – marsbard May 19 '15 at 08:56
  • 1
    Actually, see the third comment on this issue for the windows workaround @GiorgioVespucci https://github.com/svenax/SublimePrint/issues/5 – marsbard May 19 '15 at 08:57
  • Thank you @marsbard, I'll apply it! – Giorgio Vespucci May 19 '15 at 10:08
  • 1
    Also, to make things clear: you'll need to have package control installed. The Printing function appears in the menu of sublime text. – Andrew Magerman Mar 07 '16 at 08: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. – AnneTheAgile Mar 17 '16 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.

Zsolt
  • 3,263
  • 3
  • 33
  • 48
  • 81
    Thanks. But really? in version 2 of a text editor there's no print functionality? Any idea why not? – John Biddle Apr 14 '13 at 22:06
  • Printing should be hardly considered in a text editor like this, I'm surprised by your shock. – MMM Apr 14 '13 at 22:17
  • 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 Apr 14 '13 at 22:22
  • 262
    A software which costs 70$ should support printing. – Oliver Jun 09 '13 at 16:13
  • Just because almost every text editor and IDE supports printing doesn't mean that Sublime Text should too. I don't see what printing has to do with coding. Besides, there are work arounds that handle the tiny amount of printing that people do. – B Seven Aug 27 '13 at 20:39
  • 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. – Dave Newton Sep 24 '13 at 17:34
  • Quoting jps - site admin from 2009: "This isn't supported yet, and while it's on the todo list, it's currently a low priority." – kenorb Oct 01 '13 at 09:24
  • 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. – Adam Tuliper Nov 10 '13 at 07:09
  • 1
    haha, oliver f. yes but i actually don't care that much that it costs $70 and doesn't print natively because it is a damn good editor :) textmate sucked at printing too at least this has a pretty easy way to fix it. yay for package manager! btw with ST3 I installed via package manager and it just worked (even though the instructions on the github page make it look complicated to install with ST3) – cwd Dec 12 '13 at 16:14
  • LOL Love how people complain but don't learn about the package manager. There are more plugins but here is one I really like mostly because it does the syntax lexing. [Print to HTML](https://github.com/joelpt/sublimetext-print-to-html) – engineerDave Feb 14 '14 at 19:02
  • 2
    @JohnBiddle actually, it's version 3 and no printing, with a feature request open for years. Seem [my answer](http://stackoverflow.com/questions/16004842/how-do-you-print-in-sublime-text-2/27537164#27537164) for more info on that. – rsp Dec 18 '14 at 00:20
  • @DaveNewton Actually a lot of people disagree with you - you may find the discussion below the official printing feature request interesting (see [links in my answer](http://stackoverflow.com/questions/16004842/how-do-you-print-in-sublime-text-2/27537164#27537164)) – rsp Dec 18 '14 at 00:23
  • @AdamTuliper-MSFT then you'll be even more shocked to find out that a lot of people are against adding printing to Sublime Text. There is a strong opposition in the discussion below the official feature request. See the answer I just posted below for links. – rsp Dec 18 '14 at 00:28
  • @DaveNewton So what? Well, personally I find it strange that there are people who don't want others to have printing in their editors. There are actually some strong opinions in that discussion. Judging from your earlier comments I thought that you may be interested to hear about it as well. Just ignore it if you're not. (For the record: I voted **in favor** of the printing feature request - over two years ago and I'm still waiting.) – rsp Dec 18 '14 at 01:40
  • @rsp But Jan is Jan, so I'm not sure those opinions count ;-) – Dave Newton Dec 18 '14 at 01:54
  • Any idea how to copy (using Highlight plugin) without line numbers and folding panel space ?? – monstro Jan 06 '15 at 21:32
  • @rsp I've read some of that feedback. Seems silly to me. Its such a standard features in apps and such a highly requested feature, those that don't want it seem to be the vast minority and considering most other tools have it, seems logical. Just because user X (one ex) says you can open it in another tool to print means nothing. Sublime IS the tool people are looking for it in. Why switch to another tool for a basic function? When notepad has it and sublime doesn't, its hard to argue (and I've printed from notepad a billion times). Anways, my .02 :) – Adam Tuliper Jan 22 '15 at 00:43
  • 2021 and printing is still not supported. TIL. – Kevin Milner Jul 21 '21 at 13:04
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
Community
  • 1
  • 1
elomage
  • 4,334
  • 2
  • 27
  • 23
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.

rsp
  • 107,747
  • 29
  • 201
  • 177
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

Community
  • 1
  • 1
kenorb
  • 155,785
  • 88
  • 678
  • 743
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.

Noah
  • 21,451
  • 8
  • 63
  • 71
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 .

tomo661
  • 88
  • 4
  • 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 Jun 16 '14 at 03: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.

Aori Nevo
  • 71
  • 6
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.

brooklynsweb
  • 817
  • 3
  • 12
  • 26
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.
Cms
  • 11
  • 3