Sunday, December 15, 2013

Re: Regular expression and VIm

Thanks everyybod


On Sun, Dec 15, 2013 at 1:24 AM, Justin M. Keyes <justinkz@gmail.com> wrote:


On Dec 15, 2013 12:38 AM, "Erik Christiansen" <dvalin@internode.on.net> wrote:
>
> On 14.12.13 18:55, Jerry Rocteur wrote:
> > This is probably the best article that I've found and used to get my
> > reg exps working within Vim.
> >
> > http://vimregex.com/
>
> The first example under "4.5 Grouping and Backreferences" at
> that site:
>
> :s:\(\w\+\)\(\s\+\)\(\w\+\):\3\2\1:
>
> is neat in its effect¹, but it's all b\ac\ks\la\sh\es!
>
> Why oh why oh why would anyone not use its human readable form:
>
> :s:\v(\w+)(\s+)(\w+):\3\2\1:
>
> where we can easily read the meaning at a single glance, now that the
> redundant backslash snowstorm is removed.
>
> ¹ Both forms swap the first two words on a line:
>
>    one two three        # becomes
>
>    two one three
>
> Could it be a disservice to new converts to teach them an obsolete regex
> dialect when it is such an obfuscated way to do things, and Vim offers a
> so much more legible alternative, which is a modern posix standard form?

In my opinion, yes. \v is not used habitually in the Vim forums I frequent,  and it has always puzzled me that Vim regulars persist in offering the 'magic' form instead of 'very magic'. For non-plugin contexts it makes no sense.  Personally I use \v liberally when editing unless I explicitly want \V or default magic behavior.

Justin M. Keyes

--
--
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
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Thanks & Regards
 Vickyb


--
--
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
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment