# Replaced matched text in Vim with pattern

Here's a minimal example of what I'm trying to do. Start with:

"this")
"that")
[hundreds of lines like this]

End with:

"this",&this)
"that",&that)
[hundreds of lines like this]

I have gotten this far:

g/"\p*"/s/)/[what to put here?]


So it correctly identifies the string that I want to copy. What I'm not sure is how to tell it that I want it to paste that string at the end. I've tried using &, but that matches the ), not the "\p*".

-
:%s/"$$.*$$")/"\1",\&\1)/ –  Stéphane Chazelas Feb 5 '13 at 22:32

:% s/"$$[a-z]*$$"/"\1"\,\&\1/g