4

I am trying to get VIM to jump to the file listed in the error. So the following is the error.

|| 1) test01(ErrorTest0)
|| java.lang.NullPointerException
||  at Line.equals(Line.java:43)
||  at ErrorTest0.test01(ErrorTest0.java:22)

I tried the following errorformat set errorformat='%.%#\ at\ %.%#(%f:%l)' , but it does not work.

So all I want it to do is jump to the file Line.java line 43 when I click on it. Am I missing something in errorfomat?

1 Answer 1

3

First thing I notice is that you have quotes in there. When using set everything after the = symbol is set to the value.

Since errorformat has spaces and backslashes my preferred way to set it is with let and single-quoted strings, then string concatenation so I can break it up into more easily parsed lines.

let &errorformat =
    \  '%*[^"]"%f"%*\D%l: %m,'
    \. '"%f"%*\D%l: %m,'
    \. '%-G%f:%l: (Each undeclared identifier is reported only once,'
    \. etc.

So in your case it's a lot easier, let's just try it like this:

let &errorformat = '%.%# at %.%#(%f:%l)'

However you could get really fancy with multiline strings, using %E and its friends to collapse those error lines down into just the relevant info in your quickfix window but I still find that to be a bit fiddly.

1
  • If you want to try the set version out though, just remove the quotes from the one in the OP. You'll still need the backslashes before the spaces though. Feb 22, 2016 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.