17

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?

4
  • 2
    What does "interpret properly" mean?
    – wallyk
    Nov 17, 2011 at 9:30
  • Related: unix.stackexchange.com/questions/7695/… (not dupe because he wants Vim as a pager) Mar 23, 2014 at 15:18
  • @wallyk: It means I want to see colors and effects, not raw codes. Mar 23, 2014 at 20:44
  • See the answer at vi.stackexchange.com/a/20496/3324: “If you have a sufficiently modern vim that has the +terminal feature, you can do :term cat somefile and you'll get a buffer with all the terminal codes interpreted. This might work better on large files than e.g. Colorizer, which made my vim unusably slow when I let it loose on a 6000-line file.” Dec 7, 2019 at 17:10

1 Answer 1

17

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.)

2
  • 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. Jan 30, 2012 at 5:50
  • That is correct, but the asker specifically mentioned ANSI within a file opened in Vim.
    – Heptite
    Jan 30, 2012 at 6:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .