Suppose a source code interpreter outputs the error messages in the following format:

M123 Warning path/to/file 123 Description message

That is:

error_code error_type file line_number message

How can I set errorformat such that I get both the error_code and message in the quickfix window? Please note that error_type can be any string, with and without numbers.

  • Unfortunately, I do not think this is possible. The message is parsed with %m, and this can only be used once. I hope I am wrong, though! Oct 9 '15 at 13:58

You can't do this with errorformat alone, but there are a couple of ways to do it. One is to filter the output of your interpreter with another program like this:

:set mp=make\ \\\|&\ error_filter

as explained in an un-indexed paragraph in the reference manual. To find it, execute :help quickfix-directory-stack and scroll up to the previous section titled "Filtering messages".

Another way is to post-process the contents of the quickfix list as described under :help QuickFixCmdPost-example.

Using either method, edit the error message to put error_code next to message and use an errorformat that sees them together as just a message (%m).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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