If you want ANSI output, I don't know of a way to accomplish that, but Vim has a :TOhtml command which I have been using in one of my Makefiles (simplified here):
vim -gf --noplugin -c 'if has("gui_running") | stop | endif' \
-c 'runtime syntax/2html.vim' \
-c 'w foo.html' -c 'qa!' foo
The first line where it runs "stop
" if the GUI is running doesn't actually stop gVim, it just minimizes it. The second line with the "runtime
" command is basically what :TOhtml does—I don't recall any more why I chose to do it that way instead of using :TOhtml. The third line writes "foo.html
" and quits, and also includes the original file on the command line, which is "foo
" in this case, and you could possibly change it to -
instead.
>
1A comment to "I don't recall any more why I chose to do it that way instead of using :TOhtml", perhaps you didn't want to load all plugins. If you use
TOhtml
instead you have to remove--noplugin
. – 244an – 2016-10-26T18:03:26.277@244an: You're right. That's almost certainly the reason. – Heptite – 2016-10-26T18:05:00.187