Explanation of This Project
This project can create C/Cpp file in File--New File prompt. But you might modify the source code to create files of many other types.
This project was created because I wanted to create new cpp file in VSCode, but had the VSCode default language set to another more used language. So want to use File--New File prompt to do this.
However, it seems that VSCode doesn't provide this feature and I search in the extension market, but don't find the desired extension. So decided to create one.
Installation and Usage
Click "Download Extension" in the right of page to download vsix file. Then in VSCode, Click three dots in the left toolbar--Extensions--Click three dots in the topright of poped up column--Install from VSIX.
In VSCode, open Extensions, type
Click menu button--File--New File to choose file type you want to create, as shown in demo gif.
When you save the file at the first time, there will be a prompt to let you input filename and select destination folder. You can delete, e.g. "Untitled-1.h" and just input "example", the file name will be
Only after saving can the syntax highlights and snippets work normally. For .h file, you need to associate .h with cpp file format manually.
To Modify Source Code
First, download Node.js:
Make sure that you install npm package manager during Node.js installation.
Then install Typescript:
Last, install vsce:
Git clone or download zip of this project to your computer.
Open terminal from the folder you get, run
Then open src/extension.ts file. Click three dots in the left toolbar--Run and Debug--Click the green button in poped up column.
It will pop up a new VSCode window, and you can try to use the extension feature as mentioned in Usage section.
If you want to add other file type, open
e.g., .x file extension, after modifying:
Then open src/extension.ts, find
You should copy this block and paste it in the
Then rename the
Then you should modify
Add command in
Now you can use Ctrl+Shift+P and type the title to use the new command, in the Run and Debug window. To let the new command be shown in File--New File, modify
Samely, note the value of
In VSCode menus, there are many groups such as
But by readding the source code, it seems that in file/newFile there is just one group: file. And it is at the top in File--New File prompt by default. New created group is under the
So if you have other extensions providing the File--New File feature, they might use the
After modifying, run terminal from the project root folder, and run:
It will create a vsix file. Install it into VSCode and you can use the new extension.