2

I am fairly new to using Visual Studio. Currently I am using Visual Studio 2015 version. Currently when I set up a new C++ console application project (with Precompiled header off or on) it displays the following:


// Name of project.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int main()

{

return 0;

}

Every time I create a new project I have to waste my time entering in my header information and comments. I would like it to look like this every time I create a new C++ console application project.


// *********************************************************************

// Name: 

// Description: 

// Date: 

// Class Section: 

// Title: 

// *********************************************************************

//Heading information
#include <iostream>
#include "stdlib.h"
#include "stdafx.h"
using namespace std;

//Main function

int main()

{

    //Pause system and end main function

    system("pause");

    return 0;

}

Is it possible to set up Visual Studio 2015 to display the code above every time I create a new project? Thanks

  • You could just make a copy of that source code, then copy / paste that code over the default code. – rcgldr Oct 30 '15 at 00:52
  • Other than the manual method of doing it yourself, I believe ReSharper can do this, but VS itself doesn't support this on its own. – Chris O Oct 30 '15 at 01:05

1 Answers1

1
  1. Create a new console application.
  2. Edit the file to be as you want it in the new one.
  3. Select "Export Template..." in the "File" menu.
  4. Walk through the wizard (choose a name for your new template, etc.)
  5. Be sure the "Automatically import the template into Visual Studio" is checked.
  6. Restart VS
  7. Select "New Project"
  8. Select "Visual C++" in the tree control on the left
  9. Select your new template in the list in the middle
  10. The usual new-project stuff (name and location for the project, etc.)

[Note: As I'm writing this, I'm looking at it in VS 2013. I don't recall it's changing in VS 2015, but it's possible.]

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111