In Visual Studio you can press SHIFT+ALT+C to create new class file. I am looking for similar shortcut for new interface file and new "basic unit test" file. I have Telerik JustCode so please do not suggest simillar product. But if a small extension exists for example, it would be nice to know. BTW I am using Visual Studio 2010 (C#).
3 Answers
There are no built-in solutions for this, but you can easily record macros (In the Tools menu):
You can rename them in the Macro Explorer (Alt+F8)
You can then assign shortcuts to those macros in Tools → Options → Keyboard.
EDIT This doesn't work for adding a new Basic Unit Test. You'll only get to the New Test selection dialog, even with this method.

- 344,408
- 85
- 689
- 683
-
Thanks for answering but this doesn't work. 1) Shortcut for `Project.AddInterface` does not work (does nothing) no matter what shortcut and feature area (e.g. Global) I set. I even disabled add-ins but it not helped. 2) Shortcut for `Project.AddUnitTest` opens `Create Unit Tests` wizard instead of just creating unit test with standard `Basic Unit Test` template. If you can improve your answer, I will gladly accept it. – Pol Jun 15 '12 at 16:10
-
I added `Project.AddInterface` command to toolbar but it is always disabled. – Pol Jun 15 '12 at 16:14
-
Rewritten. Sorry for not testing. Alas, this one only works half either. – Joey Jun 15 '12 at 16:54
Rather than using a macro, I would advice you to look into the Code Snippet Manager. It enables you to set up a template of text with "holes" in it. And assign the template to a "key" - a short text (which can be autocompleted). When the key is typed the template replaces the key and the holes can easily be filled out. Further, you can add macro-like functionality to it, to automatically get the current filename or class or date pre-filled.
Visual studio actually is shipped with C# snippets for "Test class" and "Test method".
See also http://msdn.microsoft.com/en-us/library/ms165393(v=vs.100).aspx
Finally, the code snippet support in Resharper (http://www.jetbrains.com/resharper/) is much better than the one in visual studio. Definitely worth checking out. A real productivity boost!

- 13,322
- 16
- 71
- 114
In the new Visual Studio 2019 (Preview, in my case) it seems that Alt-Shift-C opens up "Add New Item" with the "Class" option selected and the cursor in the (file) name field. However, at that point you can simply switch from "Class" to "Interface" or any other available item.
If "Basic Unit Test" is missing then that might be because your project is not a test project; the items listed seem particular to the project type.

- 90,524
- 13
- 150
- 263