6

I have error or warning messages from some tool with the following format:

2022-08-18T21:25:01.972 WARNING ##]  file:///Users/myuser/somedir/file.txt:123: Error: something went wrong

One of the built-in error formats erroneously matched the leading timestamp and file:// as part of the file name. I need a format that ignores all of the stuff in the beginning but can’t come up with one. I don’t quite understand the advanced options from :h errorformat. The version I have is this but it of course includes the beginning of the line in the file name as well: %f:%l:\ %t%*\\a:\ %m.

How can I fix my errorformat so that only the actual file name is matched?

i.e. this: /Users/myuser/somedir/file.txt

1 Answer 1

5

You can use regular expressions as part of your errorformat definition.

See section Pattern matching under :help errorformat for more details on the exact syntax to use in errorformat specification, for example you want %.%# for the equivalent of the .* regular expression.

In your case, you can use:

%.%#]%\\s%#file://%f:%l:\ %t%*\\a:\ %m

This will skip everything up to ]\s*file:// (where the \s* part matches optional whitespace) and start matching the %f at that point.

(You can also try to incorporate the %t matcher in your expression, to capture the error type, which is WARNING in your example.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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