1

:help errorformat lists the basic items supported in 'errorformat' and one of them is:

%*{conv} any scanf non-assignable conversion

What does that mean and how can I use it?


The fscanf documentation says:

Each conversion specification has the following format:

  • introductory % character
  • (optional) assignment-suppressing character *. If this option is present, the function does not assign the result of the conversion to any receiving argument.
  • ...
  • conversion format specifier

It sounds like %*c would suppress assignment to a character, which sounds like a non assigned conversion to me. I assume it would consume that character without including it in the quickfix entry. However, using :set efm=%*c%m|cgetbuffer gives "E375: Unsupported %c in format string."

4

After studying the historical (back to vim 2.0) and current source code and documentation, I have concluded the doc is wrong. More precisely, it is out of date by more than 20 years.

The doc is wrong

errorformat plainly does not support "any scanf non-assignable conversion" and this fact is known to the author, given by a comment in src/quickfix.c:

// TODO: scanf()-like: %*ud, %*3c, %*f, ... ?

In implementation, vim does not actually use scanf or any of its variants and differences are to be expected (despite the doc's suggestion).

What does work

So which {conv} are actually valid?

vim supports %*[^a-z0-9], i.e., regex-like character classes. This matches with scanf's usage of [set], although vim's is more general. Additionally, due to implementation details, vim supports any backslash character group like %*\d. This is not in line with scanf, but could be useful.

What happened here?

At at one time vim did actually use sscanf and thus the doc comment was correct (at least for a particular set of versions of sscanf). However, in vim 5.4, the code was rewritten* to use a custom implementation which instead builds a regex pattern from the errorformat. %*<> was not fully implemented and the TODO above was added.

*I do not know why exactly this was done, except for a passing comment in the source code that mentions sscanf might sometimes be slow.

1
  • 1
    thanks for digging back that far. How about creating a issue/PR for that? Oct 21 at 6:34

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.