Am 2015-04-23 10:37, schrieb Claus Atzenbeck:
Hello everybody,
I came across a strange behavior of Vim. Consider the following two
lines; the 2nd line starts with spaces.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Test test test
Test test test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I want to match each 1st word of a line, ignoring preceding white
spaces. The expression
/\v^\s*\zs\w+
works perfectly, however,
/\v^(\s*)@<=\w+
does not. It only matches words in the very beginning of a line, but
not those preceded by whitespaces. I cannot see why the latter would
not be equivalent to the first expression.
According to
:h @<=
"Vim allows non-fixed-width patterns". Thus, I would expect the
positive lookbehind to work also for the 2nd line. (I know that \zs is
the preferable solution anyway, but I'm curious.)
Any ideas?
Well, at least, this is consistent with both regexp engines ;)
I think the problem is, that the '^' prevents a match of the following
word.
I am not sure, why this happens, or if this is expected, but what seems
to work
is to include the '^' into the capturing group, e.g.
/\(^\s*\)\@<=\w\+
That works.
Best,
Christian
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.