IntelliJ Idea: 2016.1 Windows 10 Pro
When I create a new project or a new class in a new project, IntelliJ helpfully includes a default header containing my name and the date. However, it also highlights the code and displays a warning about the file using a "Default File Template". It suggests two ways to correct the code. Either by editing the template or by replacing it with an actual file template. However, neither option satisfies the warning; nor does manually replacing the contents of the header. I can't figure out a way to get rid of it.
I know that I can suppress the warning, but I would prefer to actually correct or fix it.
Any ideas?
Press Ctrl+Alt+S to open the IDE settings and select Editor | File and Code Templates. and specify the template name, file extension, name of the resulting file, and body of the template. Apply the changes and close the dialog.
IntelliJ IDEA stores global templates in the IDE configuration directory under fileTemplates.
The point of it is to remind you to document your code by adding a description of the class. No matter what you set the template to, if you don't change the text that is in the template, it assumes you want a reminder to override it with some useful information. If you are not in the habit of adorning your code with informative comments, then you can disable that particular check.
To disable the check, where you see the comment block highlighted as a warning, click in that shaded area, wait for the "light bulb" intention icon to appear near the left margin, then, when it pops up a box that says "Edit template...", instead of clicking on the words, click on the little arrow to the right of the words, and select "Disable inspection".
Just add a new line after Default Template statement which has name and date. Intellij considers that new line as part of documentation, and then stops complaining.
Update
Like this:
/** * Created by YourName on 2017/06/11. * THIS LINE */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With