/vscode-new-file-now

Visual Studio Code extension to create new files from the command palette 🆕

Primary LanguageTypeScriptMIT LicenseMIT

New File Now 🆕

Create new files and directories quickly using the command palette.

Install from Visual Studio Marketplace

Inspired by the awesome AdvancedNewFile extension for Sublime Text.

Washing your code. A book on clean code for frontend developers

How it works?

  1. Press the hotkey: Cmd+Alt+N on Mac or Ctrl+Alt+N on Windows.

New File Now extension dialog

  1. Type a path to a file or a folder you want to create, relative to the currently open file.

Creating a file

  1. Press Enter.

New file opened in the editor

Features

Creates all the necessary nested folders, and opens the created file in the editor:

Creating nested folders

To create a folder, append / on a Mac or \ on Windows to the path. For example, taco/cat/:

Creating a new folder

To go up the file tree, start the path with ../ on a Mac or ..\ on Windows. For example, ../tacocat.txt:

Creating a file in a parent folder

To create a file or folder in the workspace root, start the path with / on a Mac or \ on Windows. For example, /tacocat.txt:

New File Now extension

Settings

You can redefine the key bindings:

Description Name Default Mac Default Windows
Create new file newFileNow.createNewFile Cmd+Alt+N Ctrl+Alt+N

Changelog

The changelog can be found on the Changelog.md file.

How is it different from other extensions?

There are plenty of similar extensions (like this or this) but they are either broken, or confusing. I wanted something that’s easy to use, efficient, simple, and has great UX. Also, they weren’t updated in years and don’t use new Visual Studio Code’s APIs.

How is it different from New Text File and New File… commands?

Visual Studio Code has several options to create new files:

  • File → New Text File (Cmd+N): creates an anonymous file, to save it you’d need to use the system file dialog and create all the folders manually.
  • File → New File (Cmd+Ctrl+Alt+N): shows a similar to the New File Now quick picker dialog, but it has a confusing UX because it’s unclear where the new file is going to be created, and it opens a system file dialog on the next step, which is even more confusing…
  • explorer.newFile (no key binding by default): creates a new file in the current folder, supports nesting and creating folders. This is close but the UX is still not as good for my taste.

All these methods are confusing and unproductive, and don’t give the user enough clarity on what’s going to happen. Most don’t create folders, don’t respect the folder of the currently open file, or dot’t let you go up. The New File Now extension doesn’t have these issues.

You may also like

Check out my other Visual Studio Code extensions:

Sponsoring

This software has been developed with lots of coffee, buy me one more cup to keep it going.

Buy Me A Coffee

Contributing

Bug fixes are welcome, but not new features. Please take a moment to review the contributing guidelines.

Authors and license

Artem Sapegin, and contributors.

MIT License, see the included License.md file.