It is not that Vim uses the secret format from C. Rather, it uses the ideas from scanf , which is a function of C. This means that the line corresponding to the error message consists of three parts:
- space
- characters
- conversion specifications
Space is your tabs and spaces. Characters are letters, numbers, and other normal things. Conversion specifications are sequences starting with the% symbol (%). In scanf, you usually map the input string to% d or% f to convert to integers or floats. In the Vim error format, you are looking for an input line (error message) for files, lines, and other information related to the compiler.
If you used scanf to extract an integer from the string "99 beer bottles", you should use:
int i; scanf("%d bottles of beer", &i);
Now with the Vim error format, this is getting a little more complicated, but it is trying to easily match more complex patterns. Things like multi-line error messages, file names, directory changes, etc. Etc. One example help for errorformat is useful:
1 Error 275 2 line 42 3 column 3 4 ' ' expected after '--' The appropriate error format string has to look like this: :set efm=%EError\ %n,%Cline\ %l,%Ccolumn\ %c,%Z%m
Here% E tells Vim that this is the beginning of a multi-line error message. % n is the error number. % C is the continuation of the multi-line message,% l is the line number and% c is the column number. % Z marks the end of the multi-line message, and% m corresponds to the error message that will be displayed in the status bar. You need to avoid backslashes, which adds a little extra oddity.
It might look simpler at first with a regular expression, this mini-language is specifically designed to help with compiler error matching. It has a lot of shortcuts. I mean, you donβt have to think about things like matching multiple lines, multiple numbers, matching path names (just use% f).
Another thought: how would you display numbers as line or line numbers to indicate files or error messages if you would use only regular regular expression? By group position? This may work, but it will not be very flexible. Another way can be called capture groups, but then this syntax is much like a short hand. In fact, you can use regexp wildcards such as .* - %.%# Is written in this language.
OK, so this is not perfect. But this is not impossible and makes sense in its own way. Stuck, read help and stopped complaining !:-)