Skip to main content

Vim: Output Colorized Source Code

You can use Vim to output colorized source code in HTML. The following command translates all the .tmpl files into .tmpl.html files:
for f in *.tmpl; do gvim -f +"syn on" +"let html_use_css = 1" +"run! syntax/2html.vim" +"wq" +"q" $f; done
To learn more, type ":help convert-to-HTML" in Vim. What's especially cool is that Vim's syntax highlighting is one of the best and most comprehensive out there.

Comments

Capt B said…
Great Blog! I was wandering if you knew code so that I can prevent my pictures and post to be copied, printed. Basically disabling the "right" clich on the mouse?? Any ideas are apreciated. Capt B
> Great Blog!

Thanks ;)

> I was wandering if you knew code so that I can prevent my pictures and post to be copied, printed.

I've noticed that you can't right-click on the map under Google maps. Perhaps if you capture all mouse down events and prevent propogation, that'll do it.

On the other hand, this is really a losing battle. The user can always take a screenshot to get images. He can also use a screenshot and then run it through a OCR to get text. I think you have to embrace the Web for what it is.

Check out: How I Learned To Stop Worrying and Relinquish Control
Brandon L. Golm said…
vim sucks. I use emacs because it rules. I can even use emacs to make toast. Having good colors is like, whatever. Do you really thing I care about my colors when I'm eating wheat toast with butter? NO!