that would also match the second line.
Important: There is no memory of what part of the errorformat matched before;
every line in the error file gets a complete new run through the error format
lines. For example, if one has: >
setlocal efm=aa,bb,cc,dd,ee
Where aa, bb, etc. are error format strings. Each line of the error file will
be matched to the pattern aa, then bb, then cc, etc. Just because cc matched
the previous error line does _not_ mean that dd will be tried first on the
current line, even if cc and dd are multi-line errorformat strings.
Separate file name *errorformat-separate-filename*
These prefixes are useful if the file name is given once and multiple messages
follow that refer to this file name.
%O single-line file message: overread the matched part
%P single-line file message: push file %f onto the stack
%Q single-line file message: pop the last file from stack
Example: Given a compiler that produces the following error logfile (without
leading line numbers):
1 [a1.tt]
2 (1,17) error: ';' missing
3 (21,2) warning: variable 'z' not defined
4 (67,3) error: end of file found before string ended
5
6 [a2.tt]
7
8 [a3.tt]
9 NEW compiler v1.1
10 (2,2) warning: variable 'x' not defined
11 (67,3) warning: 's' already defined
This logfile lists several messages for each file enclosed in [...] which are
properly parsed by an error format like this: >
:set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-Q
A call of |:clist| writes them accordingly with their correct filenames:
2 a1.tt:1 col 17 error: ';' missing
3 a1.tt:21 col 2 warning: variable 'z' not defined
4 a1.tt:67 col 3 error: end of file found before string ended
8 a3.tt:2 col 2 warning: variable 'x' not defined
9 a3.tt:67 col 3 warning: 's' already defined
Unlike the other prefixes that all match against whole lines, %P, %Q and %O
can be used to match several patterns in the same line. Thus it is possible
to parse even nested files like in the following line: >
{"file1" {"file2" error1} error2 {"file3" error3 {"file4" error4 error5}}}
<
The %O then parses over strings that do not contain any push/pop file name
information. See |errorformat-LaTeX| for an extended example.
Ignoring and using whole messages *efm-ignore*
The codes '+' or '-' can be combined with the uppercase codes above; in that
case they have to precede the letter, e.g. '%+A' or '%-G':
%- do not include the matching multi-line in any output
%+ include the whole matching line in the %m error string
One prefix is only useful in combination with '+' or '-', namely %G. It parses
over lines containing general information like compiler version strings or
other headers that can be skipped.
%-G ignore this message
%+G general message
Pattern matching
The scanf()-like "%*[]" notation is supported for backward-compatibility
with previous versions of Vim. However, it is also possible to specify
(nearly) any Vim supported regular expression in format strings.
Since meta characters of the regular expression language can be part of
ordinary matching strings or file names (and therefore internally have to
be escaped), meta symbols have to be written with leading '%':
%\ The single '\' character. Note that this has to be
escaped ("%\\") in ":set errorformat=" definitions.
%. The single '.' character.
%# The single "*"(!) character.
%^ The single '^' character. Note that this is not
useful, the pattern already matches start of line.
%$ The single '$' character. Note that this is not
useful, the pattern already matches end of line.
%[ The single '[' character for a [] character range.
%~ The single '~' character.
When using character classes in expressions (see |/\i| for an overview),
terms containing the "\+" quantifier can be written in the scanf() "%*"
notation. Example: "%\\d%\\+" ("\d\+", "any number") is equivalent to "%*\\d".
Important note: The \(...\) grouping of sub-matches