On Friday, August 17, 2012 7:46:07 AM UTC-5, Paul Anton Letnes wrote:
> Hi,
>
>
>
> this is possibly me not being regex proficient enough, but here goes: When I search for patterns with 'not newline' at the end, for instance, "/&[^\n]", the "[ ]" part seems to match "/&\n". I have realized that using simply "/&." is a simpler and better regex, but nevertheless - why doesn't my first suggestion work as expected?
>
>
I can reproduce this on 7.3.622 on Windows XP. I'm not sure why it doesn't work. On the other hand, [...] groups NEVER match newline characters, unless you explicitly add it by including \n in the group or by using \_[ instead of just [. See :help /[\n]
I think the behavior might actually be documented. :help /[/n] actually explicitly says "The same can be done by including '\n' in the collection. The end-of-line is also matched when the collection starts with '^'". I thought this referred to just when it starts with \_, but technically it SAYS the two act in the same way. It appears they actually do.
>
> Furthermore, I notice (using the hlsearch option) that the pattern [\n] matches _everything_. This must surely be a bug?
>
>
This I cannot reproduce. [\n] only matches newline characters for me on 7.3.622. But [^\n] matches everything. Assuming the above discussion of the help text is accurate, I would EXPECT [^\n] to match everywhere. It basically acts like a \_. atom.
>
> The same applies to these two vim versions:
>
> $ mvim --version
>
> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Sep 18 2011 16:00:17)
>
> MacOS X (unix) version
>
> Included patches: 1-315
>
> Compiled by Bjorn Winckler <bjorn.winckler@gmail.com>
>
>
>
> $ vim
>
> paulanto@courant:/tmp/paulanto $ vim --version
>
> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 2 2012 18:54:34)
>
> MacOS X (unix) version
>
> Included patches: 1-69
>
> Compiled by paulanto@courant.local
>
>
>
> Operating system: Mac OS X 10.7.4
>
>
>
> Cheers
>
> Paul
--
You received this message from the "vim_use" 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
Friday, August 17, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment