Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wrote a vim syntax highlighting file for a custom file type that I am working and I want to be able to show off my syntax highlighting painlessly by converting my view of the page into an HTML document for others.

My current workflow is basically:

vim *.ext

and then:

:TOhtml
:wq
:n

ad nauseum

I'm sick of it, I've exported 3 files this way and I've had enough. How can I streamline this using some sort of script?

share|improve this question
    
You can almost use :argdo, like :argdo TOhtml | wq. But while that exports the HTML files, they aren’t highlighted, because “while this command is executing, the Syntax autocommand event is disabled [to] speed up editing each file.” – Rory O'Kane Oct 18 '14 at 23:22
    
About :TOhtml: if you have a file hello.c open, :TOhtml will open a new buffer editing the nonexistent file hello.c.html, containing HTML with syntax-highlighting CSS in it. You can run :wq to save that HTML file and close the new window. – Rory O'Kane Oct 19 '14 at 0:07
up vote 3 down vote accepted

Try this:

for i in *.ext; do vim -c TOhtml -c wqa $i ; done
share|improve this answer

Create a recursive mapping:

:map <F2> :TOhtml<enter>:wq<enter>:n<enter><F2>

And then press <F2>. All your files will be converted automatically.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .