Vim Tips Wiki
Register
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=218
 
|previous=218
 
|next=220
 
|next=220
|created=February 22, 2002
+
|created=2002
 
|complexity=basic
 
|complexity=basic
 
|author=scott urban
 
|author=scott urban
Line 33: Line 33:
 
----
 
----
   
Is this somehow better than running make from within Vim using the <tt>:make</tt> command?
+
Is this somehow better than running make from within Vim using the <code>:make</code> command?
   
 
I have an alias like this:
 
I have an alias like this:

Latest revision as of 05:19, 13 July 2012

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.

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? 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.