views:

219

answers:

4

How can I get code with syntax highlighting into a word processor?

It's for a manual that will have code examples which should be able to go from page to page so putting images is not an option.

I'd rather do it with OpenOffice but I could also use iWorks or Office. The code is Ruby, Java, Python and maybe others. I could use TextMate to export it if necessary.

+2  A: 

XCode does that already, I think. If you copy out of its window and paste into another app that accepts rich text, the formatting comes along with it. I just made a screenshot:

screenshot

Carl Norum
Visual Studio too, that I know. But sadly not a viable option for the choice of languages.
Joey
XCode highlights python and java for sure. I don't have a ruby file to try. I pasted into TextEdit, MS Word, and some others.
Carl Norum
I just made a test ruby file, and that worked too. Looks like this should cover the OP's question?
Carl Norum
A: 

See http://www.fauskes.net/nb/syntaxms/

Greg
A: 

http://www.scintilla.org/SciTE.html

bugtussle
+1  A: 

VIM has a syntax hilighing for almost every programming language, and has option to export hilighted source as HTML file that should be easily imported by word processor. Use

:TOhtml
el.pescado