Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Insert File Template Header

When you create a new java class in Intellij a file header is automatically inserted (based on "File Templates" options). Is there a way to insert that same template into an existing java source file? I was hoping there was a way to use my template definition on existing code without doing a cut/paste all over the place. The template makes use of macro expansion and I hope to be able to keep that. There is a similar function in eclipse called "Generate Element Comment" that would handle this case. Does this exist within Intellij IDEA?

Any help would be much appreciated.

like image 384
jmq Avatar asked Jan 24 '11 04:01

jmq


People also ask

How do I create a header in IntelliJ?

Press Ctrl+Alt+S or choose File | Settings (Windows and Linux) or JetBrains Rider | Preferences (macOS) from the menu , then choose Editor | File Header Template on the left. In the File Header Text area, insert an arbitrary text that you want to insert into your code files.

How do I add copyright header in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Editor | Copyright. From the Default project copyright list, select the profile you want to use as the default profile. Apply the changes and close the dialog. After that you can add the copyright to the necessary files.

Where are IntelliJ templates stored?

IntelliJ IDEA stores global templates in the IDE configuration directory under fileTemplates. Project: configure file templates specific for the current project. These templates are available to everyone who works on this project. IntelliJ IDEA stores them in the project folder under .


1 Answers

Use Copyright header instead. Configure your Copyright profile as stated at jetbrains.com. Press Alt-Insert or Right mouse click -> select "Generate" -> "Copyright".

You can check what variables you can use in Copyright statement here.

like image 158
kinORnirvana Avatar answered Sep 30 '22 19:09

kinORnirvana