Skip to main content
2 of 2
deleted 16 characters in body
muru
  • 25.1k
  • 8
  • 83
  • 144

Unexpected substitution behavior

I need to put a comma between any two digits in a string of digits. For example, I want this

12345678910

to become this

1,2,3,4,5,6,7,8,9,1,0

The approach I took was the following

s/\([0-9]\)\([0-9]\)/\1,\2/g

Strangely enough, the substitution command above when applied to the string in the example gives

1,23,45,67,89,10

If I apply the substitution command once again, it gives what I want. But why just one instance of the command don't work?

The vim version I'm using is

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 18 2020 18:29:15)
Larara
  • 133
  • 3