Theme

Highlighting code syntax in Keynote

One of the many time-consuming activities associated with giving technical talks at conferences (something I love doing) is highlighting the code syntax, like in my recent talk at State of the Browser:

Richard speaking at State of the Browser, with 12 lines of syntax highlighted code on a slide.

Until today I didn’t know any way to do this beyond manually selecting each bit of code and changing its colour, one selector, one property, one value at a time. I recently switched from coding in the seemingly abandoned Espresso to Panic’s excellent Nova. Built right into Nova is a ‘Copy with Syntax Highlighting’ feature, which does just what you’d want it to in terms of pasting ready-formatted code straight into Keynote (or wherever).

Nova app, showing Copy with Syntax Highlighting feature built into the native Edit menu.

And then, such is the way of these things, I stumbled across Sara Soueidan’s blog post which showed how to do the same thing in VS Code. Sara also pointed to the handy Slides Code Highlighter utility made by Roman Nurik, which achieves the same thing regardless of your choice of code editor.

Slides Code Highlighter interface, showing formatted code readying for copying.

It’s a nice reminder that despite everything, there are still nice people doing nice things for others for seemingly little reward. And speaking of which, for completion I should point you towards Prism, a free syntax highlighter developed by Lea Verou and others, and used on millions of websites including this one. It also works in ePub ebooks.