Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make vim parse my multi-line error message for the quickfix window?

Tags:

vim

I want to run my app under vim using make, and I want the quickfix window display my errors.

So I have this format, which first starts with Error: and then filename, line and column separated by : and then on the next line, there's gonna be a multi line message with no special formatting, then the message will end with ErrorEnd.

So here's an example:

Error: /somefile/something/something.c:12:123
SOME MESSAGE 
ANOTHER HELPFUL MESSAGE
ANOTHER MESSAGE
ErrorEnd

I'm kinda lost in the documentation to how to make it match those lines. Everything seems so confusing and the examples aren't like this one. I know how to make it match the first line, but no idea how to make it match the next lines as the error message. So the question is what would be a errorformat string that could parse it all.

like image 809
Farid Nouri Neshat Avatar asked Feb 15 '23 23:02

Farid Nouri Neshat


1 Answers

You can capture multiple lines of text in the error message by using the %+ prefix as described at :help efm-ignore in combination with the multi-line errorformat specifier %E, %C, %Z, etc. described at :help errorformat-multi-line. In your specific example, the following seems to work:

let &l:efm='%EError: %f:%l:%c,%-ZErrorEnd,%+C%.%#'

Note the %+C item which matches any text on the line and adds it to the error message. Note also how I had to put the %-Z item before this item for it to be used, since the first matching errorformat item will be used when parsing the line.

like image 110
Ben Avatar answered May 21 '23 05:05

Ben