[英]Killing Python with a keybinding in VS code
I'm experimenting with some Python code that generates sound.我正在试验一些产生声音的 Python 代码。 I'm using VS code.我正在使用 VS 代码。 I've set up a keyboard shortcut for the "Python: Run Python File" action, which starts the sound playing in a terminal window.我为“Python:运行 Python 文件”操作设置了键盘快捷键,该操作会在终端 window 中开始播放声音。
In order to stop the sound, I have to first click in the terminal panel and then I can do CMD-.为了停止声音,我必须先单击终端面板,然后才能执行 CMD-。 (Mac equivalent of ctrl-C.) This takes a couple of seconds though, and if my code is unexpectedly producing a very loud sound I'd like to be able to stop it as quickly as possible. (Mac 相当于 ctrl-C。)但这需要几秒钟,如果我的代码意外地产生了非常响亮的声音,我希望能够尽快停止它。
So my question is, is there a way I can set up a keybinding to immediately stop the running Python process, without first needing to click in the terminal panel where it's running?所以我的问题是,有没有一种方法可以设置一个键绑定来立即停止正在运行的 Python 进程,而无需先单击它正在运行的终端面板?
There are a number of actions that sounded like they should work, such as "Terminal: Kill the Active Terminal in Editor Area" (bound to CMD-w by default).有许多听起来应该起作用的操作,例如“终端:杀死编辑器区域中的活动终端”(默认绑定到 CMD-w)。 However, this just seems to close the source file without affecting the terminal at all.但是,这似乎只是关闭源文件而不影响终端。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.