Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to view and edit a file in Vim, but this file has ANSI escape codes:

^[[1m[0.05s elapsed, 00:00:13 total]^[[0m

How can I tell Vim to interpret them properly instead of just showing the raw code?

share|improve this question
2  
What does "interpret properly" mean? –  wallyk Nov 17 '11 at 9:30
    
Related: unix.stackexchange.com/questions/7695/… (not dupe because he wants Vim as a pager) –  Ciro Santilli Mar 23 at 15:18
    
@wallyk: It means I want to see colors and effects, not raw codes. –  Nathan Fellman Mar 23 at 20:44

2 Answers 2

up vote 9 down vote accepted

It sounds like you want to display ANSI colors and conceal their escape characters. You can do this with Charles Campbell's "AnsiEsc" plugin.

Note that you will need Vim version 7.3 or newer. (Older versions of Vim could be patched, but that's more work for an outdated version of Vim.)

share|improve this answer
    
This works, if the file is in a buffer. However it doesn't work great if you are running a command like rake or cucumber that puts the command output not in a buffer. –  Ivanoats Jan 30 '12 at 5:50
    
That is correct, but the asker specifically mentioned ANSI within a file opened in Vim. –  Heptite Jan 30 '12 at 6:51

You can't.

On Unix-like systems, vim uses those same escape sequences to move its cursor around and perform syntax highlighting. Interpreting such sequences in the data would interfere with editing.

Consider, you press arrow down, vim scrolls a new line into the bottom line, that line ends with a clear-screen sequence.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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