Using templates to create a Class.h file and a ClassTest.cpp file?


I have a very class creation pattern that is very common to me.

1) I create a MyClass.h file. I almost always code exclusively in .h files. There's a few things that is always the same for that file:

#pragma once

//Legal comment

A class inside a namespace

2) I create MyClassTest.cpp file. The same applies to this file as for the above almost, except it also includes a couple of boiler plate unit test includes.

3) There is a pattern to where these two files are located from each other, but I'm fine with the .h file being created in the Test folder. Even if I have to move it manually it still saves me a lot of time.

My question is if there is a way that I can create a template to help me with this?

1 comment
Comment actions Permalink

Hi Olof.

It hasn't been implemented yet.

For now you can:
- Change "C header file" and "C source file" file templates (note the "C file header" helper) according to you needs (e.g. place license text here)
- Create a C/C++ live template like this:

namespace $NAMESPACE$ {
class $CLASS$ {

It will allow you to insert the template and jump between the placeholders with tab/shift-tab. Also you can provide some default values via "Edit variables" buttons. Please find out more via and

If it is inconvenient for you, please file a feature request in our tracker describing your situation:


Please sign in to leave a comment.