I think what you're looking for is described at https://www.jetbrains.com/help/idea/using-file-and-code-templates.html