What’s the best way in VIM using search and replace to add the number 1 after every FIRST comma on a line? Each line has multiple commas (this is a csv), I want to insert the value 1 though after the first comma on each line.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I believe just
:s/,/,1/should do it. If you don’t use thegoption, it will only replace the first instance found per line.Do
:%s/,/,1/if you want it to apply to the entire file, the first option only does it for a single line.