Vim Tips Wiki

Run make from command line and open Vim on errors

Redirected from VimTip219

1,623pages on
this wiki
Add New Page
Add New Page Talk0
Tip 219 Printable Monobook Previous Next

created 2002 · complexity basic · author scott urban · version 5.7

A simple alias (*csh) or shell function (bash) will let you run make from your shell, then automatically open vim or gvim on the errors (if there were any):

csh or tcsh:

alias Make 'make \!* |& tee make.errors || gvim -q make.errors -c :copen'


Make () { command make "$@" |& tee make.errors || gvim -q make.errors -c :copen ; }

If you use vanilla sh or ksh or even cmd.exe, you can probably do the same - add a note if you have ideas.


The '|&' before the 'tee' doesn't work on Bash version 3.00.15(1)-release. I had to take out '&' for it to run.

What does the '&' make the pipe do? Answer: pipes both stdout and stderr.

Is this somehow better than running make from within Vim using the :make command?

I have an alias like this:

alias vmake 'vim -c make! -c cwindow'

Much more elegant, in my opinion.

After added this to ~/.bashrc

Make () {
   make "$@" 3>&1 1>&2 2>&3 | tee make.errors
   N=`wc -l make.errors|cut -d ' ' -f 1`
   if [ $N"x" != "0x" ]; then
       vim -q make.errors -c :copen

Compiling your program, Ex:

#Make clean all

If error happened, then vim invokes automatically.

Also on Fandom

Random Wiki