source code -> syntax highlighted html

11 views
Skip to first unread message

Greg Ercolano

unread,
Jan 6, 2023, 2:19:38 AM1/6/23
to fltkc...@googlegroups.com
Here's a fun tip if you need a quick way to convert your .cxx or .H files
into syntax highlighted html so it can be viewed in a web browser.

Just open the file in VIM and type:

    :TOhtml

It generates an HTML version of your file with syntax highlighting in a new buffer
you can then save as whatever.html, then open in firefox/chrome/whatever.

It even handles utf-8 encoded text, as many code highlighters cannot.
To change the fonts/colors/text size you can tweak the css at the top of the html.
It's amazingly simple.

I like to review code on my tablet when at restaurants and such without wifi or
internet access. My tablets have terrible source code viewing tools, but the browsers
are pretty solid and handle browsing/zooming well.

Here's a screenshot in firefox of the quick results from the above:

Reply all
Reply to author
Forward
0 new messages