6

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 ?

12

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.

  • 3
    This is the most badass thing I've ever seen. +1 million – Stefano Borini Nov 18 '10 at 10:26
  • Really awesome.. +1 billion – Apple II Mar 4 '12 at 7:07
  • 2
    alias vimtohtml="vim -c 'set nonu' -c TOhtml -c wqa" - To directly convert without opening the file in vim: vimtohtml <filename> – Bharath K Oct 25 '16 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.