Turning off "created by" header when generating files in CLion
Asked Answered
R

2

21

When you create file in CLion, the following header is placed in the top of file:

//
// Created by <username> on 14.01.18.
//

Someone can remove this header by go to SettingsEditorFile and Code TemplatesIncludesC File Header. There will be text:

#if ($HEADER_COMMENTS)
//
// Created by $USER_NAME on ${DATE}.
#if ($ORGANIZATION_NAME && $ORGANIZATION_NAME != "")
// Copyright (c) $YEAR ${ORGANIZATION_NAME}#if (!$ORGANIZATION_NAME.endsWith(".")).#end All rights reserved.
#end
//
#end

I can delete this text and header will be removed. But looks like if I set $HEADER_COMMENTS variable to false then header will be removed too. So my question is:

What is $HEADER_COMMENTS variable and how can I change it?

Rathskeller answered 13/1, 2018 at 21:49 Comment(1)
Related bug report: youtrack.jetbrains.com/issue/CPP-2819Alcot
A
18

See https://www.jetbrains.com/help/clion/creating-and-editing-file-templates.html

Apparently the variable ${HEADER_COMMENTS} is always true and used for testing purposes, so you can't influence it.

Alcot answered 16/1, 2018 at 13:21 Comment(0)
C
11

I found this post at when searching to do the same thing. I didn't want to delete the whole thing as I'm using CLion for college and I might have a use for a template but I don't like the current one. I "fixed" it by making the test a not if for now. I said I'd put it here in case anyone else came searching for the same idea.

#if (!$HEADER_COMMENTS)
//
// Created by $USER_NAME on ${DATE}.
#if ($ORGANIZATION_NAME && $ORGANIZATION_NAME != "")
// Copyright (c) $YEAR ${ORGANIZATION_NAME}#if (!$ORGANIZATION_NAME.endsWith(".")).#end All rights reserved.
#end
//
#end
Collins answered 31/1, 2020 at 17:41 Comment(1)
Nice. You can also use Apache Velocity template comments (#* ... *#) to comment out the header. velocity.apache.org/engine/devel/user-guide.html#commentsImperfective

© 2022 - 2024 — McMap. All rights reserved.