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 love vim's syntax highlighting. It does particularly well on unified diffs, so I use it very often like that:

diff -pu old new | vim -

I'm aware of one tip to use vim as a better less, but what I really want a way to simply output colored output (no paging). I'm sure it can be done, but how?

share|improve this question

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.

share|improve this answer
+ for you script. It's amazing – c0rp Jul 31 '14 at 6:03

Unfortunately I can't comment the question, this is why I write an answer and hope that a more privileged user converts my entry to a comment.

For the usage of diff, you can also try something like:

svn diff |colordiff

colordiff does a great job by coloring diff output, maybe you give it a try for this specific situation. Otherwise, Heptite's answer is the correct approach.

share|improve this answer

You must log in to answer this question.

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