[英]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.