copy vim text, colors included

7

2

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 ?

Stefano Borini

Posted 2010-11-18T08:46:57.000

Reputation: 2 034

Answers

13

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.

nperson325681

Posted 2010-11-18T08:46:57.000

Reputation: 1 401

3alias vimtohtml="vim -c 'set nonu' -c TOhtml -c wqa" - To directly convert without opening the file in vim: vimtohtml <filename> – Bharath K – 2016-10-25T20:11:01.670

3This is the most badass thing I've ever seen. +1 million – Stefano Borini – 2010-11-18T10:26:22.017

Really awesome.. +1 billion – Apple II – 2012-03-04T07:07:09.610