On Thursday, January 3, 2013 2:51:38 AM UTC-6, martinwguy wrote:
> On Tuesday, 28 June 2011 13:57:37 UTC+2, Andy Wokula wrote:
> > Strange: one can't write a collection with range [X-Y] where Y is the
> > character ']'.
> >
> > I thought the following should work, but it doesn't:
> > /[@-\]]
> >
> > Is it a bug that '\' after '-' in a collection is taken literally?
>
> No, that's normal vi behaviour. \ is not special in a character range (it
> stands for itself) and to include ] you need to specify it as the first
> character in the range.
I disagree, and consider it a bug. :help /\] says:
- To include a literal ']', '^', '-' or '\' in the collection, put a
backslash before it: "[xyz\]]", "[\^xyz]", "[xy\-z]" and "[xyz\\]".
(Note: POSIX does not support the use of a backslash this way). For
']' you can also make it the first character (following a possible
"^"): "[]xyz]" or "[^]xyz]" {not in Vi}.
For '-' you can also make it the first or last character: "[-xyz]",
"[^-xyz]" or "[xyz-]". For '\' you can also let it be followed by
any character that's not in "^]-\bdertnoUux". "[\xyz]" matches '\',
'x', 'y' and 'z'. It's better to use "\\" though, future expansions
may use other characters after '\'.
This works:
/[[\\\]]
This does not work, even though it should do the same thing if the above help
entry were implemented as stated:
/[[-\]]
Using your example, this does work, but I would not expect it to:
/[][-\]
I would expect this to not be treated as a collection at all, because the
closing ] has a \ in front.
There is obviously at least a documentation bug here.
--
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