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.
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.
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.
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 .
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.
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