I'm writing a compiler script for python. I have this errorformat that correctly parses Tracebacks:
CompilerSet errorformat=
\%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,
\%Z\ \ \ \ %m
I don't understand why I need the extra escape before the comma: why can't \"%f\"\\, be \"%f\"\,? I understand that the comma needs to be escaped because it's used to delimit sections of the errorformat, but why two backslashes?
Here's an example of a Traceback where the single escape doesn't work, but the double does:
Traceback (most recent call last):
File "test.py", line 9, in <module>
g()
File "test.py", line 7, in g
f()
File "test.py", line 4, in f
raise IndexError()
IndexError
Another similar example is this python compiler script that uses three backslashes!
(I ask in the hopes that understanding why will make it easier to write more efm settings.)
From :help efm-entries:
To include a comma in a pattern precede it with a backslash (you have to type two in a ":set" command). To include a backslash itself give two backslashes (you have to type four in a ":set" command). You also need to put a backslash before a space for ":set".
Inside 'errorformat', a comma is special, namely an entry separator. To match a literal comma, you have to escape it (once): \,. Okay, but in :set there's another round of escaping (e.g. to deal with spaces in the value), so the \ gets escaped another time: \\,. Often, you can avoid that second round of escaping by using :let (but not in the :CompilerSet command here).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With