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.
Like this article?
Buy me a coffee👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.