I have occasion to need to print code (Horrors!!! ;) ), and i was wondering what editor or tool would i use to print that code out with proper formatting and syntax highlighting
Visual Studio will, and allows you have a completely separate configuration for printing.
I while ago I created a household python script that wraps pygments into a small console utility. It works with any language supported by pygments.
Also if you happen to use eclipse, you could simply copy the selected text in the editor and then paste it in a RTF-aware editor like MS Word - it will preserve all the colors, fonts and formatting.
The tool called enscript
is very much the tool for doing this. It is very powerful, is not tied to an editor nor a language and you can create PDF's with syntax highlighting.
The documentation pretty much says it all.
enscript man page
If you have problems with Visual Studio 2012 concerning the highlighted printing an handeling the described problem:
Add this line to ~/.bashrc
if you are using UBUNTU
or, to ~/.bash_profile
if you are using MAC
If that file does not exists, create it.
alias lprc='vim -me -c ":syntax on" -c ":hardcopy" -c ":q"'
source ~/.bashrc
or source ~/.bash_profile
To print colored hello.py just do this:
lprc hello.py
instead of lpr hello.py
http://pygments.org/ is one option. It supports a ton of languages, and since it's written as a python library, you can script the conversion process however you want.