String argument to interpolation

What is the fastest way to convert string argument to string interpolation? I mean to change

Method(stringVar)

to

Method($"{stringVar}")

Sometimes I need to add some text or another variable. I know I can write $ after the (, but then I have to cut the argument and paste it into {}. I can start with cutting, writing $, {} and pasting. I can write + "" after the argument and use hammer to convert to interpolation. But all this seems quite long for such a short operation. Especially when I need to do this a few times in a row. Is there a faster way? Can't find anything in the refactor zone.

0
2 comments

You could define a custom Live Template to add the string interpolation expression quicker. Refactoring cannot work till the AST is established, your input could not be predicted, so it's not applicable here.

0

Thanks a lot, that's exactly what I was looking for. It works like a charm from context actions → surround with, and when I use a shortcut. I have one last question though. If I use a shortcut e.g. “i” - it works, but when I put a shortcut “$” it doesn't work. Is it impossible to use “$” as a shortcut?

0

Please sign in to leave a comment.