Ingo Karkat wrote:

> On 14-Mar-2015 02:11, James McCoy wrote:
> > On Fri, Mar 13, 2015 at 09:54:18PM +0100, Ingo Karkat wrote:
> >> it's possible to avoid escaping a "[" character:
> >> 
> >> ,----[ :help E769 ]---- | When the ']' is not there Vim will not
> >> give an error message but | assume no collection is used.  Useful
> >> to search for '['. `----
> >> 
> >> But when using that feature in a :substitute command, the
> >> replacement part is mistakenly added to the pattern:
> >> 
> >> :s/[//g E486: Pattern not found: [//g
> > 
> > No, that's not what's happening.  You can leave off the entire 
> > replacement and the delimiter before it.  When this happens, Vim
> > treats it as deleting the matching strings.  To quote:
> > 
> > If the {string} is omitted the substitute is done as if it's empty.
> > Thus the matched pattern is deleted.  The separator after {pattern}
> > can also be left out then.  Example: > :%s/TESTING This deletes
> > "TESTING" from all lines, but only one per line.
> 
> Right. My point is that because the "/" delimiters are not actually
> left off (they are there, in the correct, unescaped form), the :s
> command *mistakenly* runs into the case you've quoted. Putting it yet
> another way, the "[" consumes the following characters (including the
> unescaped separators), assuming they belong to the collection, and
> when at the end the collection isn't closed, the parsing should
> backtrack and reinterpret, but it currently doesn't.

I understand that this is confusing, but it's working as documented.
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.  It's clear that if you type the wrong command
things may go wrong.  That's what we have undo for.

-- 
MORTICIAN:    What?
CUSTOMER:     Nothing -- here's your nine pence.
DEAD PERSON:  I'm not dead!
MORTICIAN:    Here -- he says he's not dead!
CUSTOMER:     Yes, he is.
DEAD PERSON:  I'm not!
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui