New Bamboo Web Development

Bamboo blog. Our thoughts on web technology.

Copying Code from Textmate to Keynote with Style

by Bartosz Blimke

A popular way of inserting code samples into Keynote presentations
is to take a screenshot in Textmate and then insert the image inside a slide. The advantage over normal copy&paste is that the code looks exactly the same as in TextMate, including font style and highlighting.

This technique has also disadvantages. Code can't be modified in Keynote so to do any last minute fixes, you have to edit a code in Textmate and repeat the whole screenshot procedure again.
Another problem is resizing. Since it's not a vector image, text loses quality when it's resized.

There is a better way! I've been using Copy with Style command, which I took from this blog post. It copies text selection as RTF so when the code is pasted into Keynote, it looks exactly the same as it looked in TextMate, including font style, size and colors. Code can be then modified in Keynote, while the style is preserved.

I also tried Copy as RTF bundle, but it changes foreground color to black, so it doesn't work well with black background in Keynote.

I found recently that many people were still struggling with the screenshot way so I created a Copy with Style TextMate bundle based on the Copy with Style command.
Just select a text in Textmate and press Cmd+Shift+C, then in Keynote paste it with Cmd+V

The result looks like this: