Reputation: 333
In gvim (v8) regexp we can specify a point in the selected region with \%V, e.g. s/\%Vabc/xyz/
. However, \%V
matches anywhere in the selection, I want something to match only at the beginning or end of the visual-selection (marks <,
>).
Moreover this regexp /\%V\_.*\%V/
doesn't select the final character of the region. \%V
is supposed to be zero-width?
So how can I specify the position of a mark, as in:
:s/\mark(
<).\zs(abc)\ze\mark.(>)/xyz/`
Upvotes: 4
Views: 169
Reputation: 172570
Yes, \%V
is zero-width; to include the last selected character, you need to append a .
to include the last character: /\%V\_.*\%V./
There are special atoms for mark positions; you can use them with the '<,'>
marks, too: /\%'<.*\%'>./
. As they are zero-width, too, the above applies here, too, so it's not a better alternative.
Upvotes: 2