By josh / May 26, 2014

How to print code from Sublime Text

Sometimes it’s nice to be able to print code.

You know, like on paper, with ink and stuff.

In my last job, one of my assignments was restyling an off-the-shelf customer portal-type website. The company wanted to rebrand the site to match its main website, so they had their design team work up some Photoshop comps.

I was the lucky guy charged with making the designer’s vision a reality.

Sounds straightforward, right?

There was a catch.

I couldn’t touch any of the existing HTML. The devs who built the site chose to lock all of the markup away in compiled binaries. I couldn’t so much as add a single CSS class to even one tag.

I was going to have to work all of my magic with CSS. That made it super critical to understand the existing markup.

The first thing I did when I started working on the project was print out the entire home page–about 10 pages worth–and go through it with a pen and highlighter until I could see exactly how it was structured.

Priting out the markup helped me spot elements in the design that weren’t doable and saved me hours of frustration later on.

So yeah, printing can be pretty useful.

Unfortunately, as everyone knows, you can’t print from Sublime.

Only that’s not really true. There are several plugins that make it possible with a clever workaround.

My favorite so far is ExportHTML.

This plugin allows you to convert the current file to syntax-highlighted HTML, then send it to a web browser for easy printing. (It even opens the print dialog for you… )

This might seem like a clunky workaround, but it actually has some advantages. The plugin is more configurable than a built-in print function would be, allowing you to enable or disable line numbers, for example. You can even specify your own syntax highlighting color scheme to control how the code prints.

ExportHTML is available in Package Control, and it supports both Sublime Text 2 and 3.

P.S. For more ways to improve your Sublime workflow, check out http://sublimetexttips.com/newsletter.

About the author

josh

1 comment
chupo_cro - October 20, 2016

Hi,

can you please explain what exactly do you mean by: ‘The devs who built the site chose to lock all of the markup away in compiled binaries.’? Does it mean the HTML was compiled to binary and how that could be done?

Regards

Reply
Click here to add a comment

Leave a comment: