Get "PHP 8 in a Nuthshell" (Now with PHP 8.4)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

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.

Create non-existent files using VS Code

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 enjoy my work (the articles, the open-source projects, my general demeanour... anything really), consider leaving a tip & supporting the site. Your support is incredibly appreciated!

Comments?