Friday, November 5, 2010

Regex \%V question

I still don't quite understand why my attempted solution to rameo's
problem didn't work... As a pared down example, why is the entire
visual range matched in this:

x = outside visual block, V = nonspaces in visual, ' ' = space in visual

/\%V\%(\S\+\s*\)*\%V

xxxxx VVV VVV VVV xxxxx - text
mmmmmmmmmmmmmmm - match
xxxxx VVV xxxxx - text
mmmmmmm - match

I don't understand how the leading spaces in the visual range can be
matched by a pattern that can't match leading spaces.

Removing the optionality, it's also weird, as the trailing space
(singular!?) isn't matched:

/\%V\S\+\s*\%V
xxxxx VVV VVV VVV xxxxx - text
mmmmmmmmmmmm - match
xxxxx VVV xxxxx - text
mmmm - match

Can anyone shed some light on this?

--
Best,
Ben

--
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

No comments: