5

I have a log file with colored log entries, where colors are defined by ansi escape codes. When I display the file (using cat or more), terminal understands the ansi codes and logs are colorful. But I want the power of VIM to do some text manipulation on log entries and yet see them colorful. Is there any plugin that can parse ansi codes in vim and color the text?

The only plugins I found were able to strip the ansi codes and show the plain text monochrome.

5

Yes: AnsiEsc.vim — ansi escape sequences concealed, but highlighted as specified (conceal), by Charles Campbell.

The "v2" version at the bottom doesn't require a patch to vim, so is probably the simplest option.

(The patch is necessary to hide the ANSI control characters in the text file.)

  • Thanks, it works. I used the v2 version and Text is colored. Maybe I use another script to suppress the ANSI characters (if I don't want to use the conceal patch). – saeedn Jul 23 '12 at 11:23
  • unfortunately it does not support some escape codes, like high intensity foreground color! – saeedn Jul 25 '12 at 11:39
0

The log files should be colored in Vim, i dont have a problem with that, are you sure your files have the right extension. For instance program.c will show C style formatting and colors.

Antonis Kalou.

  • 2
    You are talking about syntax highlighting, which is different from raw ANSI escape codes embedded in the text. – jw013 Jul 23 '12 at 12:09
  • Oh yes, sorry, i seem to have read the question incorrectly, my mistake. – Antonis Kalou Jul 23 '12 at 21:26

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.