Vim Tips Wiki
Register
Advertisement
Tip 219 Printable Monobook Previous Next

created February 22, 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'

bash:

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.

Comments

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?


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
   fi
}

Compiling your program, Ex:

#Make clean all

If error happened, then vim invokes automatically.

Advertisement