I was looking for a way to color stderr so when I ran :!make target, I'd see the stderr lines pop up in red so I could more easily see what stopped my build.

Inspired by this answer: https://serverfault.com/a/59279, I made the following file:


exec 2> >(while read line; do echo -e "\e[01;31m$line\e[0m" >&2; done)

Then I'd run vim via:

BASH_ENV=~/.vim/vim_bash vim

When I'd do :!make target-with-error, the stderr text now shows up as red. Everything looks right to me.

I was wondering if there's a better way to color stderr. I'm mostly interested in avoiding some "gotchas" that I haven't thought of with using the exec command in this manner. Thanks.

For those who tried this and like the effect, add let $BASH_ENV=~/.vim/vim_bash to your .vimrc or .vim/vimrc file.

  • 3
    What's the question here, exactly? – muru Dec 15 '15 at 19:22
  • 4
    You should read :help :make. – romainl Dec 15 '15 at 19:54
  • Definitively, use the quickfix feature, then you can always add/define a syntax highlighting to highlight the errors. – Luc Hermitte Dec 16 '15 at 8:36
  • Also important: :help 'errorformat' – Vitor Dec 16 '15 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.