[英]VS Code assist for Python create new method if they not exists?
I am new to VS code and Python :).我是 VS 代码和 Python 的新手 :)。 I am trying :)我在尝试 :)
Java is my main coding language and I use(love) IntelliJ IDEA for coding. Java 是我的主要编码语言,我使用(喜欢)IntelliJ IDEA 进行编码。 I chose VS code for python(for many reasons I cannot control)我为 python 选择了 VS 代码(出于许多我无法控制的原因)
In InteliJ when coding java , InteliJ code assist prompt for creation of new methods if they not exists, I found this very useful( check attached image)在 InteliJ 编码 java 时,如果新方法不存在,InteliJ 代码辅助提示创建新方法,我发现这非常有用(查看附件图片)
I couldn't find equivalence in VS code for python, Is there is any extension I can use to get this behaviour and many other InteliJ assists( eg: suggestions) ?我在 python 的 VS 代码中找不到等价物,是否有任何扩展可以用来获得这种行为和许多其他 InteliJ 协助(例如:建议)?
1. My Code Actions extension 1. 我的代码操作扩展
After installation, add configuration in settings.json
according to the format.安装完成后,按照格式在settings.json
中添加配置。
Eg:例如:
"my-code-actions.actions": {
"[python]": {
"import {{diag:$1}}": {
"diagnostics": ["\"(.*?)\" is not defined"],
"text": "import {{diag:$1}}\n",
"where": "afterLast",
"insertFind": "^(import |from \\w+ import )"
}
}
}
Effect:影响:
2. Custom code snippets 2.自定义代码片段
open in sequence File > Preferences > Configure User Snippets .按顺序打开File > Preferences > Configure User Snippets 。 Select python in the command palette.在命令面板中选择python 。 This will create a python.json
file in which you can customize the code segment according to the rules.这将创建一个python.json
文件,您可以在其中根据规则自定义代码段。
Eg:例如:
"Print to console":{
"prefix": "defHello",
"body": [
"def Hello():",
"${1: }print('Hello worle')",
"$2",
],
"description": "print hello world"
}
Effect:影响:
我不必寻找其他地方,我选择了由 InteliJ 开发的PyCharm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.