Fandom

Vim Tips Wiki

Run make from command line and open Vim on errors

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

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'

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.

CommentsEdit

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

Compiling your program, Ex:

#Make clean all

If error happened, then vim invokes automatically.

Also on Fandom

Random Wiki