I have the following text:

," abc def , qwerty ghans , ghjt bnsn 5667w !*? ",

I want to match and substitute the commas in between ," AND ", for another character (or better yet, remove them).

2

There are 2 best solutions below

0
On

A nice way in my opinion is using substitute in Visual mode.

start visual(using v) on ,", search for the ending characters using /", in order to select all the characters within the pattern, and than, when you press : in order to write a command, the following will show: :'<,'>, which means the command will be applied on the selected zone. finally, :'<,'>s/,//g will do.

0
On

Plugin solution

My PatternsOnText plugin provides (among others) a :SubstituteInSearch command. For your example, I'd select the text (non-greedily) via ,"\zs.\{-}\ze", and then run the substitution on it:

:SubstituteInSearch/,"\zs.\{-}\ze",/,/X/g

Built-in alternative

If there are few occurrences, you can get by with selecting the area, and then (and this critical part is missing from @user2848844's related answer!) restricting the matching via the special \%V atom:

'<,'>s/\%V,/X/g