gpt4 book ai didi

visual-studio-code - 如何在 VSCode 中同时创建一个新文件夹和多个文件?

转载 作者:行者123 更新时间:2023-12-05 01:10:19 51 4
gpt4 key购买 nike

我最近在 Visual Studio Code 中发现,我可以使用以下模式同时创建一个新文件夹和一个新文件:Test/Test.jsx

例如。

1:右键单击并选择“新建文件”。 New File

2:输入所需的文件夹和文件名。 Enter folder and file name

3:第 1 步和第 2 步的结果。 Folder and file creation

有人知道是否可以使用类似的模式创建一个包含多个文件的文件夹?这是我希望能够做到的。 Add multiple files to a new folder

最佳答案

我不认为你可以按照你展示的方式做到这一点,但通过一项任务很容易做到这一点。在你的 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"
}
]
}

还有一些键绑定(bind)来触发任务(在你的 keybindings.json 中):

[
{
"key": "alt+j",
"command": "workbench.action.tasks.runTask",
"args": "new react folder and files",
}
]

这将提示输入目录名称,然后在其中创建文件夹和两个文件。

[我使用 bash 命令 mkdirtouch 来创建文件夹和文件,如果您使用的是没有这些命令的 shell,则将您拥有的命令换掉。]

create a react folder and files with a task

关于visual-studio-code - 如何在 VSCode 中同时创建一个新文件夹和多个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64248732/

51 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com