Question

The line I am tyring to search and replace is this -

(assert (if (>= xAltB_0 yAltA_0) (= after_A0_B0 true) (= after_A0_B0 false)))

Now I want to replace all the occurences of B_0 by C_0 and B0 by C0.

Can I use wild-card logic of vim search and replace to do this thing?

I used this command :s/B[_]0/B\10/g but it is not really working.

Can someone help please? Thanks !

Was it helpful?

Solution

[_] means one of _ i.e. precisely _
If you mean either _ or nothing say 0 or 1 of _ like this: _\?
Don't forget to put it in a group using \( and \) to use it with \1
i.e.

:%s/B\(_\?\)0/C\10/g
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top