简体   繁体   English

vs代码的python扩展

[英]python extension for vs code

I have a problem with python autocomplete in visual studio code.我在 Visual Studio 代码中遇到了 python 自动完成的问题。 The only way I can trigger the autocomplete function is with the Tab or Enter key.我可以触发自动完成功能的唯一方法是使用 Tab 或 Enter 键。 Brackets and dot does not have any effect (or better it just hides the suggestion box and puts the bracket in place on the unfinished word eg -> typing pr in the editor would display the suggestion box with print as the first choice, if i then press bracket i end up with pr() instead of print() ) I presume there should be some settings so autocomplete would act "normally" but I can't find it.括号和点没有任何效果(或者更好的是它只是隐藏建议框并将括号放在未完成的单词上,例如 -> 在编辑器中键入pr将显示建议框,打印作为首选,如果我然后按括号我最终得到pr()而不是print() )我认为应该有一些设置,所以自动完成会“正常”运行,但我找不到它。

This is set by the shortcut key.这是由快捷键设置的。 Open the Default Keyboard Shortcuts ( File > Preferences > Keyboard Shortcuts ) and search for "acceptSelectedSuggestion".打开默认键盘快捷键文件>首选项>键盘快捷键)并搜索“acceptSelectedSuggestion”。 You will see that there are only two settings by default, the Tab and Enter keys.您将看到默认情况下只有两个设置, TabEnter键。

在此处输入图像描述

If you want to add other buttons to trigger typing intellisense, right-click on one of the settings and select Add Keybinding ,如果要添加其他按钮以触发键入智能感知,请右键单击其中一项设置并选择Add Keybinding

在此处输入图像描述

then press the button you want to set, and press Enter to save.然后按你要设置的按钮,按回车键保存。

I think you don't need to use the python autocomplete extension.我认为您不需要使用 python 自动完成扩展。 You can just use the Python extension.您可以只使用Python扩展。

Tab or enter is required to actually make a selection .需要 Tab 或 enter 才能实际进行选择 Otherwise, you could have custom function printStuff , and typing pr( would not necessarily pick the right one.否则,您可以使用自定义函数printStuff ,并且键入pr(不一定会选择正确的函数。

From what I can tell, PyCharm works the exact same way, so unclear what "acts normal" means in this context.据我所知,PyCharm 的工作方式完全相同,因此不清楚在这种情况下“行为正常”是什么意思。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM