I use Google closure-compiler to check syntax errors in a JS file, the problem is that if there is no error it gives the source of the file to its STDOUT and with the default settings this counts as an error and clutters the quickfix window.

In Bash I can do this: $closure-compiler foo.js 1>/dev/null and then it gives only errors, otherwise nothing.

But is it possible to specify this command to the Vim makeprg option? I tried many ways to no avail, for instance this:

set makeprg = closure-compiler\ %\ 1>/dev/null

doesn't return STDERR as well as STDOUT.


 set makeprg = closure-compiler\ %\ '1>/dev/null'

treats 1>/dev/null as a file name, etc.

I know I can create a Bash-script but is it possible to do it only in vimrc?

Thank you.

I suppose there is no way for this without the bash-script, since errors are STDERR only for closure-compiler, but Vim (I suppose) uses the terminal program and for it STDERR of closure-compiler becomes STDOUT, so that Vim doesn't receive STDERR in this case but STDOUT from the terminal.

2 Answers 2


Currently I did it with the help of the eval bash program:

set makeprg=eval\ 'closure-compiler\ %\ 1>/dev/null'

This approach doesn't require a separate bash script, so make can be called independently of the cwd. The minus of this solution is that it can safely be used only in terminal with the bash shell.


Vim includes a feature called quickfix that consists of a way of compiling source code using an external program and processing its output. Any failures are loaded as an iterable list into the quickfix-window.

You can also check the vim help pages for errorformat, which defines filtering expressions to identify error messages in the output of 'makeprg' (the option that determines what external program is used to process the code).

Alternatively, simply install Syntastic. I can see a reference to Closure Compiler here, so it should be supported.

  • 1
    thank you for the answer, I really appreciate this, but your answer, actually, doesn't answer the question. I know about the quickfix feature, that is why I'm asking about the redirection for the makeprg program, because I use quickfix.
    – d.k
    Jun 25, 2017 at 15:32
  • And I don't want to mess with the errorformat option, since it's kinda complex and closure-compiler already gives error messages in a format, which is understood by Vim out of the box, so I'm sure there is no need to change errorformat. I want something simpler, even simpler that an unnecessary plugin, why to install it just for one feature, which could be achieved with a simpler approach, like using the eval command or a bash script.
    – d.k
    Jun 25, 2017 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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