8

I have some nicely colored logs from some tools with bash color codes. When I view them through less or similar tools it get color rendered by bash (obviously). However it is pain to watch and edit them in any text editor like vim, because Ansi escape sequences that describes colors gets mangled and becomes really annoying to select edit, cut, paste, etc. etc..

I have ugly stuff like this when watched by vim or any editor:

0:00:00.001474526 ^[[334m11931^[[00m      0x21df400 ^[[36mDEBUG  ^[[00m ^[[00m       

So:

  1. Is there anything like plugin for vim to color text according these bash color descriptors. Anything like that. If Vim could highlight text according Ansi escape sequences for more pleasant viewing.
  2. If above is impossible how to pipe log through something and have colorless output feed to vim for it to be at least editable.
2
  • Well by default both more and cat outputs colored log. I am trying to man flag which produces colorless output.
    – IBr
    Commented Jan 10, 2014 at 13:46
  • Just for reference, bash doesn't do any coloring. It's your terminal emulator that does the coloring (xterm, gnome-terminal, whatever). All it does is output text, it doesn't render anything.
    – phemmer
    Commented Jan 10, 2014 at 14:43

1 Answer 1

7

You're looking for the AnsiEsc.vim - ansi escape sequences concealed, but highlighted plugin; it uses the conceal feature to hide the ANSI escape codes, and defines syntax groups to color the text inside Vim.

screenshot

2
  • I'll give it a try.
    – IBr
    Commented Jan 10, 2014 at 13:55
  • 1
    The AnsiEsc.vim page mentions a "conceal" patch. This patch is not needed in Vim 7.3 and later. vim --version | grep conceal will show a line containing "+conceal" if your version supports it.
    – Jander
    Commented Jan 13, 2014 at 5:54

You must log in to answer this question.

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