-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I don't see this particular behavior documented. I would expect
something like this (highlighting the current inconsistencies):
"An unclosed [ will do a literal search, but when such pattern is
directly included in a :substitute command (but not when such pattern
is reused from the last search via :s//...), the remainder is
interpreted as the pattern; i.e. you cannot add a replacement part and
:s_flags there.
> The alternative, detecting the unclosed [ in some circumstances,
> will make it less consistent and probably even more confusing. So
> let's just leave it as it is.
I've never argued for that. Of course, the unclosed [ would have to be
detected in _all_ circumstances. That shouldn't be too difficult; the
regexp engines already do that.
> It's clear that if you type the wrong command things may go wrong.
I don't think :s/[/x/g is wrong. It simply parses as pattern=[,
replacement=x, flags=g. Unfortunately, Vim's implementation is buggy
and parses it as pattern=[/x/g replacement= flags= (because the [...]
collection parsing suspends the delimiter parsing until the closing ],
but this isn't a collection, so it shouldn't apply!)
If I had wanted that, I would rather type :s/[\/x\/g (or
:s/[\/x\/g//), i.e. properly escape the / delimiters.
> That's what we have undo for.
As I said, I'm mostly worried about plugins blindly putting @/ into
the :substitute (maybe with prepending / appending something else, and
then failing due to the inconsistency caused by the bug. That would be
hard to detect by the user; undo wouldn't help much.
I'm all for consistency, and fixing this bug would IMO increase that,
so that the special case of unclosed [ and the :s/// separators
interact in a benign way. I was motivated to report this because one
Vim user was struggling with just this, and went to Stack Overflow to
ask for help.
- -- regards, ingo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
iQEcBAEBAgAGBQJVBIifAAoJEA7ziXlAzQ/v4TsH+gPD7aPCR98auBnAzamL97QB
kewrhUxGy/VtL3sNq8gfjhK/hHx3TyFT+hmcxEhsKHpHw5XT2WnBnagUVadZ1t6l
JD4yxcdxf2z7Rj5RL5Is4hSP/dCJseYydByZcACaPwdeZJ3YJQz1buRFNTjNF4MU
vf0DBaNi6VIULfaQl2QnWiH3p7B2qcp/qPRkuT7Zt6V9SRRBmUx/GfpRCKMW9BWg
89uHCPV77GqRU8EUawdzq3WnxMEb4PJMZiZVwcxLvm6eBqi8WpCIw9+W/oPWqj+3
j2nwXmOzUybc8rp+Y4zojSLsUuhl/Kr9BVG9xo6h9NN1Eq7uUoMzdS8iBJPC2gE=
=AmaI
-----END PGP SIGNATURE-----