VSCode: Keyboard shortcut to create a file in a specific project folder?

Viewed 1574

I have a project open, with many folders and subfolders. I would like to create a file. I know specifically which folder the file should exist in.

Is there a way to create a new file in a specific folder, without using the mouse?

Note: I've also opened an issue on the vscode github repo here, referencing suggestions from this stackoverflow: https://github.com/microsoft/vscode/issues/117509

2 Answers

Just in case someone ends up here, add this to your keybinding:

{
    "key": "ctrl+n",
    "command": "workbench.files.action.createFileFromExplorer",
    "when": "explorerViewletFocus && explorerViewletVisible && !inputFocus"
}

Found it in the github issue mentioned by @Duane J above

To know how to find and edit the keybindings.json file refer to this link

It is also nice to create files and folders from the command line. To open the terminal, which is integrated in VSCode, press Ctrl+`.

Then to create a new file inside a folder of your choice you can use common command-line syntax such as:

touch ./<myFolder>/<newFile>


[Edit:] By the way, it is also possible to open the file just created without using the mouse. Press arrowUp and change the word "touch" to "code", which is the command to open VSCode:

code ./<myFolder>/<newFile>

Related