Key bindings for live templates

I can't seem to find a way to do this, so I hope I'm just not looking in the right place :). I used to have a macro/template that would surround my selection in parentheses and place the caret at the left side of it, so that I can easily transform something into a function call. It has proven to be really useful, as I am missing it bigtime now that I cannot find a way to do it. Therefore: is it possible to set key bindings for live templates? Or is there maybe another way to achieve what I just described?

2
5 comments

Hi there,

Assigning custom shortcut to a specific Live Template -- no.

But you can always select the text and then invoke "Code | Surround with Live Template" -- you will see all applicable "surround" Live Templates listed there.

 

P.S. You may try recording a Macro (for which you can assign custom shortcut) .. but I'm not sure that it will play back nicely in such context.

1
Avatar
Permanently deleted user

I had indeed found out about that one (the surround by live template option), but that is indeed not what I was looking for :). Thanks for your reply though!

0

So .. are you missing an actual ability to assign a shortcut to any Live Template ... or you cannot create/use Live Template for surround context?

if 1st -- it's not possible (not implemented); if 2nd -- show your live template.

0
Avatar
Permanently deleted user

I am able to use the live template to surround my selection. However, I would like to be able to trigger this functionality using a key binding. And since you say that is not possible, I guess my search for an answer ends here, with an answer! Thanks ^^.

0

https://youtrack.jetbrains.com/issue/IDEA-67811

Consider voting for it -- hopefully having more votes will bring it closer to "implement in next version" list

Other than that -- go through plugins -- maybe one of them offers something like that already (not live templates but custom "Surround with function call" action)

1

Please sign in to leave a comment.