I have been trying, unsuccessfully, to add quotation marks around some numbers in my file using regex. To clarify, let me give an example of what I am trying to do.
Something like myFunction(100) would be changed to myFunction("100").
I thought :100,300s/\([0-9]*\)/"\0" would work but it put quotation marks around spaces as well.
What can I do to fix this?
You should slightly modify the regular expression:
%s/\(\d\+\)/"\1"
In regular expression, first matched group is \1, not \0. And it looks safer to use \+ instead of *.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With