4

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?

1

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.

  • 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
3

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

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

  • 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/less.sh -n' – Aaron D Feb 16 '15 at 8:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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