0

Suppose I have following pattern:

throw "some message";

which I'd like to replace with:

throw new Error("some message");

So, "some message" part should not be changed (or copied as is), and everything around it should be changed with arbitrary strings.

Is there any way to do that in Emacs?

  • Seems like this question should be a duplicate, but I don't have time now to search for that... Anyone else? – Drew Oct 23 '19 at 13:58
  • What is the major mode of the buffer? 2) Do you always throw literal strings in the original version or do you sometimes format them?
  • – Tobias Oct 23 '19 at 15:30
  • @Tyler: Capturing a group is here only a small problem compared to finding the right buffer-substring. – Tobias Oct 23 '19 at 17:28
  • 1
    @Tobias the accepted answer indicates that capture groups was the crux of the issue. I think you've answered a much more complex question than the one OP actually asked ;) – Tyler Oct 23 '19 at 18:33