Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 want to generate HTML files in batch to show some gvim colorschemes in action. I took my current solution from the script at, but this will open open a gvim window for each colorscheme I want to process.

So far, the only way I have found to avoid the annoying new windows that pop up every second is to start a VNCserver and set the DISPLAY environment variable to that of the VNCserver so that all gvim windows are sent to the display within the VNC session.

However, I would like to know if there is a way I can avoid the whole VNC setup and just run a headless gvim instance that does the conversion and exits, with no windows ever being actually displayed.

I'm using linux, BTW.

share|improve this question
vim -E -c "TOhtml" -c "w" -c "qa!" -- test.c >/dev/null

Use vim, it will load faster than gvim. You can speed up the loading time a bit by using -X, or a No-X version of vim.

In order to silence it, use >/dev/null. But that will make vim complain (Vim: Warning: Output is not to a terminal) and pause a bit, hence we use -E.

We could have tried -E -s, but I'm somehow unable to use :TOhtml properly, the result is uncolored, and is one a single line.

I pimp the command a little by using -R -c "set noreadonly" or better -n alone. This prevents the usual warning message when opening a file that already has a swapfile. There is nothing particular to prevent failures to open a non writable file (eg. owned by root).

See my vimcat repository at GitHub, for an example usage of vim syntax highlighting used in a terminal.

share|improve this answer

I can't really tell whether your problem is that Vim opens too many windows at once, or that it opens any windows at all...

The latter case I can't help you with, however, in any newer Vim, you can do something like this (very primitive, can probably be made a lot nicer):

# gvim -c TOhtml -c w -c q -c q test.c

which will create a test.c.xhtml based on the file test.c using the current color scheme. Then, perhaps another -c to change the colors, stick it all in a shell script...


with no windows ever being actually displayed.

Yeah, so, I'm a moron. Please disregard this post.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.