vim repeat a pattern in a replace command

Viewed 929

I have the following text:

Lang1
Lang2
Lang3

Now I want to replace all the text in each line with a pattern like:

{ DisplayName: DispName(Lang1), Value: Lang1 },
{ DisplayName: DispName(Lang1), Value: Lang2 },
{ DisplayName: DispName(Lang1), Value: Lang3 },

Now how do I achieve this with the vim command substitution, I can get: :%s/*$/\{\ DisplayName\:\ DispName\(Lang1\)\,\ Value\:\ Lang1\}\,/ to replace each line with Lang1 and then replace the individual 1s with 2, 3, 4, etc. But I do not want to do that. I want a single substitute command to select the pattern and repeat it. How to achieve this ?

1 Answers
Related