Syntax Highlighting Exterior Your Editor – A Checklist Aside

Article Continues Beneath

Whether or not you’re giving a chat, sharing work together with your crew, or presenting work to your shoppers, there comes a time if you’ll want to indicate code exterior of a textual content editor. Copying and pasting code from a textual content editor to say, Keynote, is a straightforward course of. The difficulties are available in if you wish to protect syntax highlighting, which is essential to bringing code to life.

I’m within the midst of constructing a couple of talks that comprise a number of code, so I’ve been exploring instruments to enhance my workflow from my editor of selection, Chic Textual content, to Keynote. I used to be on the lookout for the simplest solution to copy code as wealthy textual content—with my most well-liked colour scheme, font face, and font dimension utilized—to be pasted instantly into Keynote.

The primary device I attempted was a Chic Textual content bundle, put in with Bundle Management, known as SublimeHighlight. With SublimeHighlight put in, you’ll be able to choose code and set off a command to repeat the code to your clipboard as wealthy textual content.

Available SublimeHighlight commands

Constructed on prime of Pygments, it’s a very nice bundle for Chic Textual content that matches my workflow completely. Nevertheless, the obtainable format choices didn’t really feel in depth or highly effective, and I gave the impression to be doing a number of tweaking in Keynote. The pace of copying instantly out of Chic Textual content was outweighed by the point I spent in Keynote.

I started on the lookout for a device that will permit me to spend much less time tweaking types in Keynote, and located Spotlight, a command line utility with a terrifying quantity of documentation. Worry not; the educational curve is low, and the chances are infinite. To put in it, both comply with the directions, or if you happen to’re operating OS X and Homebrew, simply run brew set up spotlight.

To attain my direct-to-Keynote nirvana, I performed with the obtainable command line choices a bit till I used to be glad. What I got here up with regarded like this:

spotlight -O rtf -t 2 -Ok 40 -k 'Supply Code Professional' --style twilight _output.js | pbcopy

Although verbose, it’s not as difficult because it seems: -O rtf units the output format to wealthy textual content, -t 2 units tabs to 2 areas, -Ok 40 units font dimension to 40, and -k 'Supply Code Professional' units the font face to Supply Code Professional, my most well-liked font face. I created a theme to match my most well-liked colour scheme, Twilight, and specify its use by together with --style twilight. To make use of this with out the customized theme, simply depart the --style twilight out.

The ultimate bit, _output.js | pbcopy, tells Spotlight to run _output.js, the file containing code to be processed, by its formatter and replica the outcomes to the clipboard. All I’ve to do is run that line, paste into Keynote, and I’ve a wonderfully formatted chunk of code.

It’s not the proper workflow by any means, however I like the quantity of flexibility and management Spotlight gives. You possibly can see how I’ve been making heavy use of this device in talks that I’ve posted to Speaker Deck.

Leave a Comment