Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Error format matches everything

I am trying to match the following error with efm:

AssertionError: 1 == 2
    at /home/strager/projects/blah/blah.js:13:37

The error message can be anything (i.e. it doesn't always match the AssertionError: .* or .*Error: .* formats). The general format is:

errormessage
    at filename:line:column

My problem is that the error message matches any line; I need to restrict the error message to one line only, and only match if it's followed by a matching "at" line.

I have tried the following efm:

set efm=%Z\ \ \ \ at\ %f:%l:%c,%E%m
" %Z    at %f:%l:%c,%E%m

This almost works, but it matches status lines (e.g. non-errors before and after the error) in addition to the errors. How can I force %E%m ... %Z to be only two lines total (one for the error message, and one for the at line)? I have access to the standard UNIX tools for makeprg if needed.

like image 707
strager Avatar asked Sep 15 '10 18:09

strager


1 Answers

Does this work?

set efm=%Z\ \ \ \ at\ %f:%l:%c,%E%m,%-G%.%#

The %-G%.%# tells vim to ignore entire lines that do not match the other patterns.

like image 112
Starfish Avatar answered Sep 30 '22 16:09

Starfish