Hi Ben! On Do, 03 Jan 2013, Ben Fritz wrote:
> 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. That is how POSIX defines it: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05 ,---- | A bracket expression is either a matching list expression or a | non-matching list expression. It consists of one or more expressions: | collating elements, collating symbols, equivalence classes, character | classes, or range expressions. The <right-square-bracket> ( ']' ) shall | lose its special meaning and represent itself in a bracket expression if | it occurs first in the list (after an initial <circumflex> ( '^' ), if | any). Otherwise, it shall terminate the bracket expression, unless it | appears in a collating symbol (such as "[.].]" ) or is the ending | <right-square-bracket> for a collating symbol, equivalence class, or | character class. The special characters '.' , '*' , '[' , and '\\' ( | <period>, <asterisk>, <left-square-bracket>, and <backslash>, | respectively) shall lose their special meaning within a bracket | expression. `---- > > 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: > > /[[\\\]] Looks like a Vim extension to BRE (as stated in your quotation from the help). > > This does not work, even though it should do the same thing if the above help > entry were implemented as stated: > > /[[-\]] Yes, the backslash doesn't have a special meaning when used within a range. Not sure, we should fix this. > > 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. Yes, but the standard demands other. However, I think /[]\-] would be more cleaner and is suggested by the standard: ,---- | If a bracket expression specifies both '-' and ']' , the ']' shall be | placed first (after the '^' , if any) and the '-' last within the | bracket expression. `---- regards, Christian -- Haben Sie Ihre Begabung von der Mutter? - Nein, ich habe sie mit der Vatermilch eingesogen. -- Heinz Erhardt -- 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
