Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANSI Color Codes in VIM

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.

like image 533
Blake Avatar asked May 15 '12 00:05

Blake


3 Answers

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:

less -R
like image 143
John Carter Avatar answered Oct 22 '22 07:10

John Carter


Use Charles Campbell's (Dr Chip) AnsiEsc plugin:

http://www.vim.org/scripts/script.php?script_id=302

Before:

before

:AnsiEsc<CR>

after

like image 43
guns Avatar answered Oct 22 '22 06:10

guns


Since the link in the accepted answer doesn't appear to be working, I found this link: https://github.com/vim-scripts/AnsiEsc.vim

like image 6
ndjensen Avatar answered Oct 22 '22 08:10

ndjensen