Reputation: 113
Hi I have a file full of strings
create_net_shape -no_snap -type path -net VDD -layer M9 -datatype 0 -path_type 0 -width 0.4 -route_type user_enter -points {{2965.64 302.835} {2979.93 302.835}}
I would like to be able to search and replace in vi , a certain field based on a result of other filed
I nedd the output to be
create_net_shape -no_snap -type path -net VDD -layer M9 -datatype 9 -path_type 0 -width 0.4 -route_type user_enter -points {{2965.64 302.835} {2979.93 302.835}}
and so on
how can I use my search result in one field and apply it into the other
thanks
Upvotes: 0
Views: 141
Reputation: 161914
Try this command:
:%s/\v-layer M([0-9]+) -datatype \zs[0-9]+/\1/
digits
right after -datatype
.digits
with those right after -layer M
:help \v
and :help \zs
Upvotes: 1