Live template & Custom Script With Groovy Script Id Gen

In this example we will create a template that generates an ID.

In Live Templates: img

We create variable with $ID$ then go to Edit variables and add Groovy script:

groovyScript("def charset = (('a'..'z') + ('A'..'Z') + ('0'..'9')).join(); return (1..24).collect { charset[new Random().nextInt(charset.length())] }.join()")

img

Now we have anchorPoint template that generates random 24 character long ID.

Run script online

Almost the same code (println instead of return) to run in Online Groovy Editor to see output:

def charset = (('a'..'z') + ('A'..'Z') + ('0'..'9')).join();  
println((1..24).collect { charset[new Random().nextInt(charset.length())] }.join())