There isn't a dedicated shortcut to create a new HTML file directly within VS Code. However, you can achieve this easily using the following methods:
Creating a New File:
- Use the "New File" command: Press Ctrl+N (Windows/Linux) or Cmd+N (macOS) to create a new, empty file.
- Save the file as an HTML file: After creating the file, use Ctrl+S (Windows/Linux) or Cmd+S (macOS) to save the file. In the "Save As" dialog box, type the desired file name, followed by
.html
(e.g.,index.html
).
Creating a New File with a Template:
- Use the "Create File" command: Right-click in the VS Code explorer panel and select "Create File".
- Type the file name: Enter the desired file name, including the
.html
extension. VS Code will automatically create the file.
Using the "Create HTML File" Extension:
- Install the "Create HTML File" extension: Search for "Create HTML File" in the VS Code Extensions Marketplace and install it.
- Use the command: After installing the extension, you can use the command palette (Ctrl+Shift+P or Cmd+Shift+P) to search for "Create HTML File" and execute it. This will create a new HTML file with a basic structure.
Practical Tip:
- You can customize the default code snippet for HTML files in VS Code by navigating to File > Preferences > Settings (Windows/Linux) or Code > Preferences > Settings (macOS) and searching for "emmet.includeVariables".
By following these steps, you can easily create new HTML files in VS Code.