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 feel that the `highlight' utility doesn't support as many file types as vim does, and the project isn't very active. When the file is gzipped, highlight doesn't recognize it at all.

But in despite of `highlight', as an alternative choice, can I have the colorized vim text output to the console?

share|improve this question
up vote 1 down vote accepted

If you insist on using vim for this you can disable clearing of the screen on exit with :set t_ti= t_te=.

To make this behave a little more light highlight you can automatically exit vim. This will however only show you one screen of higlighted source. Additionally you would need to :redraw the screen to actually see something.

Also use the view alias of vim to open the file read-only.

$ view --cmd "set t_ti= t_te=" "+redraw" "+q" YOUR_FILE

A way more natural solution would pygmentize from the pygments python package.

share|improve this answer
Well, the usage only gives one screen, but at least it gives one screen. What I want is to utilize the highlight function of vim, maybe I have to hack into the source code. – Xiè Jìléi Aug 2 '10 at 12:18

vim can act as a replacement for less, while adding features such as vim's syntax highlighting, by running /usr/share/vim/vimcurrent/macros/

I haven't used highlight, so I'm not sure if this is what you're looking for or not.

share|improve this answer
You can use the -n flag to ignore the case when the file is already open in another vim window and has a swap file. My .bashrc - alias vless='/usr/share/vim/vim73/macros/ -n' – Aaron D Feb 16 '15 at 8:56

You must log in to answer this question.

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