Reputation: 2657
I have a number of lines like this:
pointer->[some Random Number Of Alphabets](),
I want to search for this pattern and append .value()
to it exactly after the ()
so it becomes pointer->[some Random Number Of Alphabets]().value(),
but what happens is it overwrites the ","
and the space after it which I'm intending to leave unaffected. the command I'm using is this:
%s/\(\<pointer->.*()\), \>/\1.value()/
What am I doing wrong here?
Upvotes: 1
Views: 164
Reputation: 45117
I like to use \ze
in these cases
:%s/\<pointer->.*()\ze, /&.value()/
\ze
marks the end of the match&
is equivalent to \0
\>
as I feel like this is an accident. See :h /\>
\{-}
instead of *
, better yet maybe [^(]*
\zs
to the mark start of the match and eliminate the need for &
. See @Pak's comment belowFor more help see:
:h /\ze
:h s/\&
:h /\>
:h /\{-
Upvotes: 1