copy vim text, colors included

I have a vim open on code, and the code is highlighted. I would like to write this code to a file, including the color codes used to highlight the text. How can I achieve this ?


Solution 1:

Vim's TOHtml achieves this. It saves the active buffer with the syntax coloring as HTML. It might be included in your Vim installation, so try ahead issuing :TOhtml.