Code::Blocks Forums

User forums => Help => Topic started by: crystoppher on July 12, 2018, 04:33:23 pm

Title: Create new Default Code
Post by: crystoppher on July 12, 2018, 04:33:23 pm
Hey guys,
I'm having difficulty creating a new default code. I like to create a default code like this.

Example

  /⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆
   ⋆  Project: $(proejct)
   ⋆  Function:
   ⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆
   ⋆  $Author: mario $
   ⋆  $Name:  $
   ⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆
   ⋆
   ⋆  Copyright 2007 by company name
   ⋆
   ⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆⋆/

I'm starting my studies in programming c. So I still have more questions about some topics.

Title: Re: Create new Default Code
Post by: BlueHazzard on July 13, 2018, 03:01:55 pm
What should this be?
Default code for new project?
Default code for every new c file?
Default code for every new cpp file?
Shortcut to paste?
Template to easily add to the project?
Title: Re: Create new Default Code
Post by: crystoppher on July 13, 2018, 07:02:07 pm
Default code for every new c file? Yes! Exactly.
I wanted to create similar code and leave saved automatically. With each new project this information should appear without having to copy and paste this code.  Is this possible???
Title: Re: Create new Default Code
Post by: BlueHazzard on July 15, 2018, 09:57:20 pm
I assume you want that codeblocks replaces the $(proejct)  with the project title and  $Name:  $  with the file name?

There are multiple ways to do this.
The easiest way is this:
Settings->Editor->Default code
Add your default code there.
You can use variable expansion (http://wiki.codeblocks.org/index.php/Variable_expansion) in your default code. So for you this would look like this:
Code
 /**************************************************************************
   *  Project: $(PROJECT_NAME)
   *  Function:
   **************************************************************************
   *  $Author: mario $
   *  $Name:  $
   **************************************************************************
   *
   *  Copyright 2007 by company name
   *
   *************************************************************************/

To trigger this template you have to use the shortcut File->New->File->C/c++ source file->Go ecc...
Title: Re: Create new Default Code
Post by: crystoppher on July 17, 2018, 10:22:28 pm
Yep!
Thanks for help. @BlueHazzard