This has to be possible!
Sep. 12th, 2007 04:03 pmI'm switching from Emacs to VIM for a variety of reasons. One thing that I can't seem to figure out how to do is perform a substitution using a regular expression with captures. What I have is:
"Offer_ID","Product_ID","Offer_ID","CodeText" 3000,0,3000,12345 3001,10,3001,67890 3002,42,3002,67890 3003,40,3003,67890
What I want is:
"Offer_ID","Product_ID","CodeText" 3000,0,12345 3001,10,67890 3002,42,67890 3003,40,67890
I think it would be easy using a command like %s/^\(\d+,\)\(\d+,\)\d+,\(\d+\)$/\1\2\3/
, but all I get is the error message "Pattern not found." Looking at the VIM help the syntax looks right and I've made sure that magic is set. So I don't know what's going wrong.
What's wrong with my substitution?
Update: Fixed typos in the post that weren't used in VIM.