User forums > Using Code::Blocks

Default code tags

(1/1)

SKiD:
Hello,

if i look in my default code editor for source files, i see an empty editor.
I want to make a new file template for header and cpp files, but i dont know how i can automatically insert the current date or author.

For example my editor default code file:

--- Code: ---// $author $date

--- End code ---

The new created code file:

--- Code: ---// SkiD 2010-02-18

--- End code ---

Did i have that possibility ?

Greetings,
SkiD.

MortenMacFly:

--- Quote from: SKiD on February 18, 2010, 08:47:02 pm ---
--- Code: ---// $author $date

--- End code ---

Did i have that possibility ?

--- End quote ---
Yes, do the following:
- Setup a variable with your name in the environment variables plugin, e.g. "author=SKID"
- Setup the code for the source file (and/or header file accordingly) as follows:

--- Code: ---// $author
// $NOW

--- End code ---
The first line: Any environment variable will be resolved. This includes %USERNAME% on Windows, but always use the dollar ($) operator in the default code.
The second line: C::B features a lot of internal macros (you can consult the C::B documentation accordingly), one of it is NOW which is date and time in a certain format. Other formats are possible but named differently (obviously).

Notice that if you are using a version control system you'd probably want to use the the macro replacement functionality of e.g. subversion.

SKiD:
Hello,

thanks for reply!
I search the environment variables plugin, but i only found a wiki-entry.

Can you tell me where i can download that plugin ?

Thank you!

MortenMacFly:

--- Quote from: SKiD on February 18, 2010, 09:49:37 pm ---Can you tell me where i can download that plugin ?

--- End quote ---
What version of C::B do you have? It's part of 08/02 and the nightlies. Just make sure (if you are using the installer) that you select this plugin to be installed. It is part of the contrib plugins. Alternatively you can also set the environment variable outside C::B and then run C::B in that environment.

Under Linux e.g.:

--- Code: ---export author=SKiD
codeblocks

--- End code ---
Under Windows e.g.:

--- Code: ---set author=SKiD
codeblocks.exe

--- End code ---

SKiD:
Okay thanks i found it!
I hava reinstalled the program and found it in the environment settings!

Thank you very much for your help to solve the problem ;)

Greetings,
SkiD.

//EDIT

Okay, iam cheered to soon.
I have insert variables with my name like that

--- Code: ---author = SKID
--- End code ---

If i want to insert that tag in my source file, the variable always show $author and not SKID.
For example:

--- Code: ---Default code for source file:
// $author

New source file:
// $author

--- End code ---

I look for the right profile in my project, but it shows always default.
My variables are created in the default profile, too.

Navigation

[0] Message Index

Go to full version