Search code examples
regexcsvvim

How to remove a specific entry from a number of entries separated by comma?


I have some entries in a csv file like below

John, 20, LA, USA
Jane, 50, NY, USA
Jim, 38, PH, USA

How can I remove the second entry from all lines in vim editor so that it looks like the following?

John, LA, USA
Jane, NY, USA
Jim, PH, USA

Solution

  • This should work:

    :%s/^\([^,]\+,\) [^,]\+,/\1/