I have a script that generates a log file with ANSI color codes in them like so:
[2012-05-14 18:00:02] ^[[0mINF: -- Starting update script --^[[0m
[2012-05-14 18:00:29] ^[[91mERR: Improper date, entry being ignored.^[[0m
Is there any way to get Vim to understand these color codes?
Thanks for any help.
AnsiEsc
works with basic ANSI color codes, but not other codes. The problem is that there are lots of ANSI_escape_code s beyond the basic\033[31m red \033[0m
; what isAnsiEsc
, what is any program, to do with\033[... unrecognized
? It seems thatAnsiEsc
just leaves such alone, but differently in Vim and mvim.Better doc on
AnsiEsc
would be welcome; links to a small ANSI escape code parser in python would be welcome.A test case for colored output from gnu ls and grep, with
TERM xterm-256color
and macosx Terminal version 2.3:See also the lovely bash script colors256 .
I'm not sure about vim, but if you're just viewing a log file (ie you don't need to be able to edit) you could use less:
Use Charles Campbell's (Dr Chip) AnsiEsc plugin:
http://www.vim.org/scripts/script.php?script_id=302
Before:
:AnsiEsc<CR>
Since the link in the accepted answer doesn't appear to be working, I found this link: https://github.com/vim-scripts/AnsiEsc.vim