My File Te...">

IntelliJ IDEA - New Template

I am trying to create a set of custom file templates for IntelliJ.

Basically I want to right-click "New> My File Template", similar to the "New> Java Class" bundled with IntelliJ.

I added my own file template using "Settings> File Templates", but they do not appear in my "new" context menu.

This is a Java project, and the template extension is java. Did I miss something?

All help is much appreciated.

enter image description here

No My Template β†’>

enter image description here

+6
source share
2 answers

If you choose Java Class, you can choose a template for your new class. This is a new feature, it was available when selecting "Create."

intellij

+10
source

Actually you can, sort of.

I do not know how to do this for Java files. but if you install the extension on txt , it will appear in the right-click menu.
Settings> File Template example

and here it is in the menu:
right click -> new file -> package-info exists

The only problem: if you create a java class, you will have to rename the file after creation in $ {name} .java

+1
source

Source: https://habr.com/ru/post/890973/


All Articles