Quickly adding new files in Visual Studio 2022

Jamie Burns
3 min readApr 6, 2022

Anyone who’s used Visual Studio for long periods of time will tell you that sometimes its handling of files and folders is less than perfect.

Don’t get me wrong — I think Visual Studio is amazing, and with all the improvements that came in with Visual Studio 2022, it’s spot-on nearly all the time. However, adding new files can still feel a little clunky.

To add a new file via the UI, you’ve usually got to go through a few steps:

  1. Right-click where you want the file to be added, go to ‘Add’ and click ‘New Item…’
  2. In the new window, wait for it to load, scroll to find the file type you want, or search for it
  3. Select the type, give it a name, and click ‘Add’, and the file is added

Ok, it’s not going to ruin your day doing this, but it’s not quite as seamless as how files can be added compared to other IDEs, like the brilliant Visual Studio Code.

This led me onto finding a handy little extension published by the talented Mads Kristensen: Add New File.

It’s a free extension that you can install either via the marketplace (https://marketplace.visualstudio.com/items?itemName=MadsKristensen.AddNewFile64) or from within the Extensions manager within Visual Studio itself (just search for Add New File).

It’s brilliant, and it’s the first extension I install when setting Visual Studio up on a new machine.

It adds a new item to the context menu in the Solution Explorer, called ‘New Empty File…’:

The ‘New Empty File…’ context menu option provided by the Add New File extension

Clicking it gives you a little prompt, where you can set the name of the file, including the extension:

Adding a new file via the Add New File extension

Give it a name, add the extension to the end, and hit ‘Add file’. And you’re done. The file is there.

For some file types (e.g., .cs files) you get some default content in the file, like a namespace, class definition, some using statements, etc. Other file types (e.g., .js files) are empty.

But what’s really cool is what you can do when naming the file. Do you want to add a file without an extension (like LICENSE)? Sure, go for it. How about adding a file that starts with a dot (like .gitignore)? Yep, no problem. Do you want to create the file inside a specific directory structure, but can’t be bothered to add each folder manually? Sure, just add the directory names to the filename:

Adding a file within a directory structure

And the directories are created at the same time:

Directories and file added at the same time

It’s so simple, but it works perfectly, and makes adding files as seamless as it gets.

--

--

Jamie Burns

Software Engineer, founder of Bungalow64 Technologies