Custom New Class Template
Visual C#

The Incorrect Way

When you add a new class in Visual C#, it is filled with a template.  You can change this.

 

Step 1.

Go to this folder (for VS2019):

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class

 

Step 2.

Edit this file in Admin mode (so that you can save it):

Class.cs

Use the variables within this template to your liking.

 

Example:
// YOUR NAME
// $time$ (Month Day, $year$)
// $itemname$

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace $rootnamespace$
{
    class $safeitemrootname$
    {
        // ---- properties

        // ---- data members

        // ---- methods

    }  // class $safeitemrootname$
}  // namespace $rootnamespace$

See what I did there?

At the end of the file, when you are editing a function at the very end, it’s annoying to see three } at the end, and I often add comments like this.  It’s very neat to have this added automatically.

It’s also cool to automatically have the proper includes, and default constructor, along with common functions you almost always make.  Deleting extra code is easier than writing it every time.

Though, to be honest, these days, I leave things alone, since I have a new mantra:

Always Type the Code.

 

Warning

Make sure you save a copy of this as some Visual Studio updates will overwrite your changes.

Thus, you should use…

 

The Correct Way

I opened a bug against Visual Studio describing the data loss, and they directed me to the correct way to do this.  It works, but it’s clumsy.  If you want to edit it, you need to go hack the files yourself in a .zip file, and then re-zip it, as explained here.  Make sure you’re in the correct folder (the one being used by VS2019, and not your Exported Templates folder).

 

Recommended Keyboard Shortcuts
Visual Studio

When setting up Visual Studio 2019, I was reminded that I need to set up a few shortcuts to make it more useful.  I thought I’d record them so I can refer to them later, and that it may help some of you.

I recommend setting the following bindings to make Visual Studio 2019 useful:

  • Ctrl+W = Edit.SelectCurrentWord
  • Ctrl+Left Arrow = View.NavigateBackward
  • Ctrl+Right Arrow = View.NavigateForward
  • Ctrl+1 = Edit.ToggleLineComment
  • Ctrl+Up Arrow = Edit.PageUp
  • Ctrl+Down Arrow = Edit.PageDown
  • Ctrl+Tab = next file tab (unsure what the name is; it may be default)
  • Ctrl+Shift+Tab = previous file tab (unsure what the name is; it may be default)

Note: You may have to delete existing shortcuts that are using these keys.

 

Welcome to The First Pixel

Welcome to THE FIRST PIXEL.

The First Pixel

The is the personal blog of Jason Doucette.

It can be considered somewhat of a subsidiary of Xona Games — my award-winning Xbox & PlayStation indie game studio, co-founded by twin brother, Matthew Doucette and I.  Our motto is “Empower the Player”, which has existed as the main pillar of game design since we first started designing & programming games from the age of 7.  Empowerment is a constant conscious presence.

As you can guess — I am into video games.

However I do not really play them.  In Grade II, a teacher allowed the entire class to play video games, so we lined up.  I asked the teacher “Do we have to play games?” and she said “No.”  Thus, when it was my turn, I shut off the video games and started coding.  The entire class booed, and I was legitimately shocked at the social faux pas I had just committed.

I have fit into society about as well as that ever since.

This blog will contain side projects and articles, including lots of retro stuff.  While most of my projects are hidden, you may view what I am working on on my GitHub page which will give up-to-date links to my YouTube videos.

— Jason Allen Doucette / THE FIRST PIXEL