Search code examples
templatesintellij-idealive-templates

IntelliJ IDEA Live Template default value as last entered value?


In IntelliJ IDEA, I'd like to create a Live Template that has a variable with a default value that updates to whatever the last thing I typed for that variable was.

For example, say I have the very simple template

$example$;

and the first time I use the template, I type "value". Obviously the text that should appear is

value;

What I'd like to happen is that, the next time I use the template, "value" is already filled in for the variable $example$ (because the last time I used the template, the value of $example$ was "value").

Is there a way to get this to happen?


Solution

  • IntelliJ IDEA doesn't have this functionality. One can probably create a plug-in that would remember the last used value and provide methods to save/restore this value for the live template functions via groovyScript().