The copy function already places the text in RTF format on the clipboard. If you copy text with syntax highlighting, and paste it in an RTF-aware application (such as MS Word), the format (font, color) will be retained. Let me know if this does not work for you.