Using maven3 with vim

Vim’s ability to execute commands from vim itself adds a great deal of productivity. Although, it’s debatable that it’s the best editor for Java, I made an attempt to work with maven3 inside vim and integrate it with vim’s quick fix list. Disclaimer: I’m not a vim expert, just an enthusiast. Please drop a comment as this tip is in need of improvements.

First, change make to work with maven. I’ve added -q so that only errors will reach the console.

set makeprg=mvn\ compile\ -q\ -f\ pom.xml

Change the error format to match maven3 output. Disclaimer: This is not perfect, but it manages to pick up the maven3 errors.

 set errorformat=[ERROR]\ %f:[%l%.%c]%m

Change your working directory to the root of the maven project with :cd

Execute make with :make

Here’s the output I get.

Now, if you have errors it should show in the quick fix list as depicted below (Use :copen to open the quick fix list)

Now navigate and fix with :cn and :cp. Cheers!

One thought on “Using maven3 with vim

  1. Pingback: JavaPins

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s