[英]Visual Studio Code run code in the same terminal
我在互联网上找不到答案,所以我在这里问。 我实际上是在Visual Studio Code上开发某种语言,例如Python。 如果我正在运行代码,它将始终打开一个新终端,因此我可以更快地打开许多终端,每次都很难关闭它们。 可以在打开的当前终端中运行代码,而无需编写我自己的“ python文件名”?
要将VSCode中的项目作为任务运行,您需要做的就是像这样创建.vscode/tasks.json
文件。 以下任务将在集成终端中打开:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run shell command",
"type": "shell",
"command": "echo 'Hello world!'",
"group": "test",
"presentation": {
"panel": "shared",
"reveal": "always",
"focus": true
},
}
]
}
在同一终端上运行的主要焦点是"panel": "shared"
行。 这将在同一终端中运行命令。
注意:此任务未经测试,因为我目前无法访问VSCode实例。
在这里,我的任务文件供任何想要更轻松地启动python文件的人使用:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run Script",
"command": "python",
"presentation": {
"panel": "shared",
"reveal": "always",
"focus": true
},
"args": [
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
使用快捷键CTRL + SHIFT + B生成任务,并在要重建时执行相同的快捷键:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.