How to replace space with comma using sed? November 30, 2023 by Tarik If you are talking about sed, this works: sed -e "s/ /,/g" < a.txt In vim, use same regex to replace: s/ /,/g