I try to read :h errorformat:

%m              error message (finds a string)

I try to read it, but I practically found that it's impossible to specify %m twice:

E372: Too many %m in format string

I want to match ctest output, that looks like so:

1/1 Test #1: testname ...........***Failed  Required regular expression not found.

I can match it with like:

 :let &errorformat='%\d%\+/%\d%\+ Test #%l: %f %[.*]%#Failed  %m'

and that will give me:

 testname|1| Required regular expression not found.

This is no ideal, as it will try to open testname file that does not exists. But I want to match Test #1: testname and the message and remove the ....***Failed part, so ideally, I would want like:

 :let &errorformat='%\d%\+/%\d%\+ (Test #%l: %f)%m %[.*]%#Failed  %m'
                                  ^^^^^^^^^^^^^^^^ like concatenates this to %m

Do I have to use an external tool (Filtering messages section from :h errorformat) (it will be sed) or is it possible to get %m twice and concatenate the message within vim errorformat?

  • 1
    Considering help says The ... "%m" conversion [has] to detect the end of the string. and all the examples show it as the last % item it looks like a direct approach is not feasible.
    – B Layer
    Jul 1, 2021 at 9:00

1 Answer 1


There is no way to do that.

Indeed, using an external tool to format the message is the way to go. The tool can be simple, sed is more than enough.

Another option is including the whole line in the message by ab-using %+ operator, like:

let &errorformat='%+G%\d%\+/%\d%\+ Test #%l: %f %[.*]%#Failed  %m'

will result in:

 testname|1 error| 1/1 Test #1: testname ...........***Failed  Required regular expression not found.

But this is a workaround - it will start a multiline message, but never end it, there may be problems with %C.

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.