Custom errorformat for quickfix

470 views Asked by At

I have an error message like

some text
some text
Error starts ---
error file1
 message1
error file2
 message 2
Error end ---

How can I parse only the contents in the error part. I want the some text ignored.

Right now for the errorformat I am using

%+C\ %.%#,%+A%f:%l:%c:\ error%.%#,%-Z%[%^\ ]
1

There are 1 answers

0
perelo On

Try this

set efm=%-GError\ %.%#\ ---,%Eerror\ %f,%+C\ %.%#,%-G%.%#
  • %-GError\ %.%#\ ---, ignore Error .* --- lines
  • %Eerror\ %f, start multi-line error, get the file name
  • %+C\ %.%#, continue multi-line error with lines beginning with a space
  • %-G%.%# ignore all other lines

This works only if you have one error per file, error messages as

error file1
 message 1
 message 2

will appear as file1 || message 1 message 2

Sidenote, for testing, you can put your error message in a file named e.g. errorfile.txt, then :set errorfile=errorfile.txt than :cgetfile (or :cg) will read the errorfile and parse it with your errorformat.

:h error-file-format