Create non-existent files using VS Code
Here’s a handy trick I recently discovered in VS Code that allows you to create non-existent files using the editor itself.
Essentially, when you try to open a file that doesn’t exist, VS Code will prompt you to create it. You can do this by clicking on the Create
button.
So, for instance, if you are trying to open a file named js/bar/foo.js
(in a <script>
tag) using Ctrl / Cmd + Click and if it doesn’t exist, it will prompt you to create it. And from there, it will automatically create the file for you.
Here’s it in action.
This will also create directories if they don’t exist. I think it’s pretty handy and saves you from having to create files manually.
👋 Hi there! I'm Amit. I write articles about all things web development. If you like what I do and want me to continue doing the same, I'd like you consider leaving a tip. I'd highly appreciate that. Cheers!