I want to create .HTML file whenever I choose New File, is this possible?
If you are using VS code then you can use this command shift + 1 and enter to auto-populate HTML Doctype in HTML or PHP.
Visual Studio Code provides basic support for HTML programming out of the box. There is syntax highlighting, smart completions with IntelliSense, and customizable formatting. VS Code also includes great Emmet support.
In VS Code, my separate folders for different HTML projects are stored under an UNTITLED (WORKSPACE).
For a new HTML file, I simply right-click on any folder in (WORKSPACE), select New File and then name that file with an HTML extension. The file is completely empty with no HTML whatsoever. Then, because the Emmet plugin is built into VS Code, I simply type an ! (exclamation point) and press TAB or ENTER and the empty file is filed with a complete HTML5 boilerplate.
5 simple steps to create an HTML file in Visual Studio Code
As far as I can see, there is no way to configure VS Code to do this out of the box so I wrote an extension to do it. You can download that extension from the marketplace.
It adds two types of commands:
editor.newFile.withCurrentLanguageMode
will open a new file with the same language mode as the currently active fileeditor.newFile.withLanguageMode.<languageId>
will open a new file with specified id as the language mode. The language must be first added to the configuration and a keybinding set up So to set up one command to open new html files and another to open markdown files, you can add settings like this:
settings.json:
"editor.newFile.languageModes": ["markdown", "html"]
keybindings.json:
{
"key": "ctrl+shift+t 0",
"command": "editor.newFile.withCurrentLanguageMode",
"when": ""
},
{
"key": "ctrl+shift+t 1",
"command": "editor.newFile.withLanguageMode.markdown",
"when": ""
},
{
"key": "ctrl+shift+t 2",
"command": "editor.newFile.withLanguageMode.html",
"when": ""
}
Using these settings you would then press "ctrl+shift+t" then "0" to open a new file with the same language as whatever file you have active, "ctrl+shift+t" then "1" to open a new file with "markdown" as the language mode, and "ctrl+shift+t" then "2" to open a new file with "html" as the language mode. Of course, you can customize the keybindings however you want and set the languages to whatever you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With