Flopi
Flopi

Reputation: 73

vim substitution of generic number

I'm trying to substitute some sequence of char by another in a file with vim. I've got this in a file : aname;1234 anothername;1456 again;1478 againBis;10253 things;10547 thingsBis;12457 etc...

and I would like to replace the ";1" sequence on each line where the number is 4 chars long by a ";01" sequence so that the number is 5 chars long.

I tried in vi :

:1,$s:;1...:;01...:g

but the substitution results in : aname;01... anothername;01... again;01... againBis;10253 things;10547 thingsBis;12457 etc...

It removes the chars after the "1"... Someone can help ??? Tahnks

Upvotes: 0

Views: 133

Answers (1)

swpd
swpd

Reputation: 1151

The following command should do what you want:

UPDATE:

:1,$s:;\(1[0-9]\{3\}$\):;0\1:g

Upvotes: 1

Related Questions