Default comment in all new source files.


Is it possible to add a "custom" comment which will be automatically added to all newly created files ?

Something like a signature in an email client, but then add the comment at the top, not the bottom.

The comment would look like this :

* Exercise : **     Chapter : **               Name-Of-Book                              *
*                                                                                                           *
* Short discription of the exercise                                                            *
*                                                                                                           *

and then the #include statement.

I asked about something similar when CLion was still in E.A.P. (having a custom template and not the "Hello World" one that is used for every new project.
So I don't know if this fits in that category or not, and if there is an ITA when such feature would be added.


Comment actions Permalink

I'm not sure I fully understand what you're looking for, but there are File and Code Templates under Preferences -> Editor.  It controls things like how default include guards are added to .h files.  You may be able to use that to make a template like the one you described.

Comment actions Permalink


Thanks for your reply.

You method works but it doesn't use this templace for the first (main.cpp) file when you start a new project.
New C source files added afterwards do work.

So I guess it partially works.

Do you also know if it's possible (and how) to add code that will automatically insert certain data ?

for example when the new file is created on April 30th that date is automatically inserted into the source file.

I think I once saw a tutorial that mentioned this, but it was for Eclipse.

Comment actions Permalink

When you open Live Template configuration there is a link to

As for predefined macros, here is Help from IDEA.
Perhaps it also works for CLion.

Along with static text, code and            comments, you can also use predefined variables (listed below) that            will then be expanded like macros into the corresponding values.
It            is also possible to specify an arbitrary number of custom variables            in the format ${<VARIABLE_NAME>}. In this case, before            the new file is created, you will be prompted with a dialog where            you can define particular values for all custom variables.
Using            the #parse directive, you can include templates from the Includes tab, by specifying the full name of the desired template as a            parameter in quotation marks. For example:
#parse("File  ")

Predefined variables will take the            following values:
${PACKAGE_NAME} name of the package in which the new            file is created
${NAME} name of the new file specified by you            in the New <TEMPLATE_NAME> dialog
${USER} current user system login name
${DATE} current system date
${TIME} current system time
${YEAR} current year
${MONTH} current month
${MONTH_NAME_SHORT} first 3 letters of the current month            name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL} full name of the current month.            Example: January, February, etc.
${DAY} current day of the month
${HOUR} current hour
${MINUTE} current minute
${PROJECT_NAME} the name of the current project
Comment actions Permalink


I completely looked over that link.


Please sign in to leave a comment.