我最近在Visual Studio代码中发现,我可以使用以下模式同时创建一个新文件夹和一个新文件: Test/Test.jsx
例如:
1:右击并选择“新建文件”。

2:输入所需的文件夹和文件名。

3:步骤1和2的结果。

有没有人知道是否可以使用类似的模式创建一个包含多个文件的文件夹?这就是我想要做的。

发布于 2020-10-08 01:38:53
我不认为你可以像你展示的那样做,但是用一个任务来做是相当容易的。在您的tasks.json中:
{
"version": "2.0.0",
"tasks": [
{
"label": "new react folder and files",
"command": "mkdir ${input:dirName} && touch '${input:dirName}/${input:dirName}.component.jsx' '${input:dirName}/${input:dirName}.styles.jsx'",
"type": "shell",
"problemMatcher": [],
"presentation": {
"echo": false,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
}
],
// ........................................................................................
"inputs": [
{
"type": "promptString",
"id": "dirName",
"description": "Complete my folder name",
"default": "jsx folder to create"
}
]
}和一些用于触发任务的键绑定(在您的keybindings.json中):
[
{
"key": "alt+j",
"command": "workbench.action.tasks.runTask",
"args": "new react folder and files",
}
]这将提示输入目录名,然后在其中创建文件夹和两个文件。
我使用了bash命令mkdir和touch来创建文件夹和文件,如果您使用的是没有使用这些命令的shell,那么可以替换掉现有的命令。

https://stackoverflow.com/questions/64248732
复制相似问题