如何在 VScode 中运行选择代码? [英] How to run the select code in VScode?

查看:60
本文介绍了如何在 VScode 中运行选择代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在VScode中运行python的select代码.到现在为止,我必须复制代码并将其粘贴到下面的终端中才能运行.系统是mac OS.那么有没有什么办法可以在我选中代码后直接运行代码呢?例如,像快捷方式.谢谢.

I want to run the select code of python in VScode. Till now, I have to copy the code and paste it in the terminal below to run. The system is mac OS. So is there any way to run the code directly after I selected the code? For example, like the shortcuts. Thanks.

推荐答案

@yanachen,这现在可以在 VS Code 中实现.您需要做的就是:
1. 确保 python 在 VS Code 终端窗口中运行
2.选择你想在python中执行的文本
3. 调用以下链接中定义的命令workbench.action.terminal.runSelectedText":https://code.visualstudio.com/docs/editor/integrated-terminal#_key-bindings

@yanachen, this is now possible in VS Code. All you need to do is:
1. Ensure python is running in the VS Code terminal window
2. Select the text you wish to execute in python
3. Invoke the command 'workbench.action.terminal.runSelectedText' as defined in the following link: https://code.visualstudio.com/docs/editor/integrated-terminal#_key-bindings

这篇关于如何在 VScode 中运行选择代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆