I try to parse output with ANSI codes and I can't cope with definition errorformat. Example output:

^[[0;31;49mtestdata/examples.rb:3^[[0m Array#shuffle.first is slower than Array#sample.$

After parse I get:

|| testdata/examples.rb:3 Array#shuffle.first is slower than Array#sample.

In this example use ANSI code red color: ^[[0;31;49m. Character ^[ is <1b> in HEX. I tried use this character in efm:

"%s/<1b>%p[0;31;49m%f:%l%s/<1b>%p[0m %m"

but it didn't work. Also I tried to use \033 character (^[ in octal):

"\033%p[0;31;49m%f:%l\033%p[0m %m"

And it doesn't work too.

  • I'm not entirely sure what you're trying to do. If you want to show colors by way of ANSI escape codes there's no native support for that but there's a plugin with this capability as noted in my answer here: vi.stackexchange.com/questions/20273/…
    – B Layer
    Mar 7, 2020 at 8:25
  • 1
    @BLayer i think OP is trying to use errorformat/quickfix with a tool that produces ANSI color codes in it’s output. Best solution is to make sure that tool doesn’t produce color when it’s output isn’t to a terminal.
    – D. Ben Knoble
    Mar 7, 2020 at 14:17
  • 1
    I'd say the best soution, then, is to use AnsiEsc (if it works with quickfix/errorformat, that is). If you expressly don't want color then hope that the relevant tool(s) have --no-color or equivalent.
    – B Layer
    Mar 7, 2020 at 17:58
  • I develop tool for a some linter. Thank you for your recommendations. I solved the problem via using linux utilit sed that remove ansi codes.
    – vk26
    Apr 6, 2020 at 16:47
  • 1
    Well-design CLI tools shouldn't output colour codes when the output is not an interactive terminal, unless explicitly told to do so. I would report it in the issue's bug tracker, as this will cause problems in various tools. Apr 6, 2020 at 19:55

1 Answer 1


After all I solved this problem using sed linux utilit. My solution:

some-cli | sed "s/\x1b\[[0-9;]*m//g" | some-errorformat-vim-tool

where sed "s/\x1b\[[0-9;]*m//g" remove all ansi-codes.

This answer helped my: Can Vim interpret terminal color escape codes?

  • 1
    Glad you solved your problem, but long term it's easier to have some-cli not generate colors when it doens't go to the terminal!
    – D. Ben Knoble
    Apr 6, 2020 at 17:15

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