try using this: http://quickhighlighter.com/
select with line numbers copy and paste
You can also use other online formatting tools (http://stackoverflow.com/questions/206441/online-code-beautifier-and-formatter), but if you want the coloring to work after pasting into a text document, the source hlml source The highline source code must be inline.
source share