Recreates the Visual Studio Add New File (Shift+F2) experience in VS Code:
press Shift+F2, type a relative path, and the file — including any missing
folders — is created and opened immediately. No dialogs, no clicking through
the explorer.
Press Shift+F2 (or right-click a folder in the Explorer → Quick Add File: New File...), then type:
| Input | Result |
|---|---|
OrderService.cs |
Creates the file next to the active file |
Services/Orders/OrderService.cs |
Creates the nested folders and the file |
Models/Order.cs, Models/Customer.cs |
Creates multiple files at once |
Docs/ |
Trailing slash creates a folder only |
/src/Program.cs |
Leading slash is relative to the workspace root |
The base folder is chosen the same way Visual Studio does it:
- The folder you right-clicked in the Explorer.
- Otherwise, the folder containing the active editor's file.
- Otherwise, the workspace root.
Existing files are never overwritten — they are just opened.
New files can start with content chosen by their extension. Built in for .cs:
namespace MyProject.Services.Orders;
public class OrderService
{
// caret lands here
}The namespace comes from the nearest .csproj walking up from the new file
(<RootNamespace> if set, otherwise the project file name) plus the folder
path below it. Files named IOrderService.cs get interface instead of
class.
Add or override templates per extension in settings:
Placeholders: {name} (file name without extension), {fileName},
{namespace}, {type} (interface for I-prefixed names, else class),
{cursor} (where the caret is placed after the file opens).
npm install -g @vscode/vsce # once
cd D:\Repos\quick-add-file
vsce package
code --install-extension quick-add-file-1.0.0.vsixOr press F5 with this folder open in VS Code to try it in an Extension
Development Host.
MIT