First, in IntelliJ, open Settings (ctrl-alt-s), under IDE Settings find File and Code Templates
and have a look at the Templates
tab.
You will see some templates there already, for example there is one called Class
:
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
public class ${NAME} {
}
Note that it includes File Header
, which is found under the Includes
tab.
Now, you can easily create your own file templates here. Under the Templates
tab, just hit the green "Add" button, give your new template a name (Foo
?),ensure the extension is java and write a valid java class.
Save, and your newly configured template exists here:
C:\Users\{USER}\.IntelliJIdea12\config\fileTemplates\Foo.java
You should be able to share this file with your team.
A neat feature is that from within the Project pane of a java project, under a source root, hit alt-enter
, choose a New Java Class and under the Kind drop-down - voila! You can see your Foo
template as a valid option.