Reputation: 1459
I want to replace X with Y in vim with the regular expression ^+.*X$
, which begin with +
and end with X
.
Upvotes: 1
Views: 85
Reputation: 59277
Yet another alternative, use the :g
command to operate in lines beginning with +
and replace the final X
:
g/^+/s/X$/Y
Upvotes: 5
Reputation: 23667
Another variant, using \zs
to indicate start of match
%s/^+.*\zsX$/Y/
See :h \zs
for more info
Upvotes: 5