Great idea. I could see how this could be a nice feature to add to some of my projects, so I did a little research and here is what I came up with:
in reply to Using vim for highlighting in Perl
The relevant reading in vim...
From the command line...
This will create yourfile.html in the current directory. I had to tweak the resulting HTML to change the background from white to black. (Perhaps since that is what my terminal background color is, that is the colors that vim used.) I would be very interested to know if you come up with any improvements on this method.
vim -f +"syn on" +"so \$VIMRUNTIME/syntax/2html.vim" +"wq" +"q" yourfi