-1

Is there any Intellij Idea hotkey or a plugin to quickly insert variable into string? e.g. i have string

"My code is working, yay! Result is = ",

and i have to add construction "+variable +", resulting in

"My code is working, yay! Result is = "+ variable +"."

to properly insert a variable.

When i have to insert variables into 20+ string, its driving me nuts :)

tried to find solution on google or plugin repository, no result

PS: i know about soutv hotkey, but it cant help me since i have to change already existing strings in code

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
Narryel
  • 61
  • 5
  • Not specific enough. Why don't you make your own live template or use multi caret? https://www.jetbrains.com/help/idea/using-live-templates.html – Meo Apr 19 '19 at 08:15
  • if all the inserted variables are the same, or all different, use multi-carets. – Mark Jeronimus Apr 19 '19 at 09:23

1 Answers1

2

Added Live Template

Abbreviation: ++
Description: Insert variable into string
Expand with: Enter
Template text: "+ $EXPR$ +" (do not forget double quotes)
Edit Template Variable: 
expression:variableOfType("") default Value: "expr"

settings screen

You type ++ in a string, press Enter, and template text is added, and you only need to choose a variable. Works like a charm.

Thanks for the idea, @Meo

Narryel
  • 61
  • 5