Reputation: 455
How do I put a part of search pattern in substitution string.
I have to replace abc->hwqe_w1_len
with common_wqe_get_len(abc)
Similarly this one def->hwqe_w1_len
with common_wqe_get_len(def)
using only one expression in vim substitute command.
I tried using the following command but it says invalid command.
:%s /\(.*\)->hwqe_w1_len/\='common_wqe_get_len(' . submatch(1) '\)'/gc
When I remove the closing brace it works, but it takes the spaces before abc
:%s /\(.*\)->hwqe_w1_len/\='common_wqe_get_len(' . submatch(1)/gc
What is the mistake I am doing? How do I put abc
with out spaces and the closing brace at the end?
Upvotes: 1
Views: 474