6

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.
  • Well by default both more and cat outputs colored log. I am trying to man flag which produces colorless output. – IBr Jan 10 '14 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. – Patrick Jan 10 '14 at 14:43
6

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

  • I'll give it a try. – IBr Jan 10 '14 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 Jan 13 '14 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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