Peng Yu wrote:
vim has a script less.sh. However, it doesn't show color. For example,
grep --color=auto can print colored text to a terminal. But if it is
piped to less.sh, no color is shown. Is there a way to have less.sh
show the same color?

1. By piping with grep --color=auto, grep itself does not "colorize" the text. Instead, you need to use --color=always .

2. grep --color=auto or always colorizes by using Ansi escape sequences. You need the AnsiEsc plugin with vim to handle them

3. AnsiEsc works best with Vince Negri's conceal patch. I've compiled a "special" vim with VN's conceal patch which I've renamed to "cvim".

4. The following command takes the grep output and runs it through conceal-patched vim with the AnsiEsc plugin:

        grep --color=always PATTERN FILENAME_HERE | cvim -c 'AnsiEsc' -

The AnsiEsc plugin colorizes text according to ansi escape sequences; you can get the plugin from:

   http://vim.sourceforge.net/scripts/script.php?script_id=302   (stable)
http://ftpmysite.verizon.net/astronaut/vim/index.html#ANSIESC (cutting edge)

You can get VN's patch from http://groups.google.com/group/vim_dev/web/vim-patches as patch#14.

Regards,
Chip Campbell


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to