1

What should I type in replace-regexp command to change the first list below into the second? I'd like to repeat each number at the beginning of line. To achieve that, I assume that I'll have to refer to each regexp match when I type what I'd like to replace each of them with, but how can I do that?

* apple
12
* banana
5
* grape
5
* watermelon
3



* apple
12 12
* banana
5 5
* grape
5 5
* watermelon
3 3
  • I found the answer here, but my question's title seems really different than the one in the link. Should I close this as a duplicate? stackoverflow.com/questions/2003774/… – stacko Jun 22 '16 at 9:40
  • 1
    No. Only duplicates of other questions on the same site are closed. It's OK for duplicates to exist on different sites. The question you cite is on StackOverflow. – Drew Jun 22 '16 at 16:32
1

Replace (i.e. M-x query-replace-regexp)

^\([[:digit:]]+\)

with

\1 \1

viola. You can look up this decent reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.