简体   繁体   English

Sublime Text 2自动补全功能

[英]Sublime Text 2 autocompletion for python

I have installed both SublimeCodeIntel and SublimeJEDI , but I am not getting the autocompletion from imported library. 我已经安装了SublimeCodeIntelSublimeJEDI ,但是我没有从导入的库中获取自动全功能。

What do I need to do to get available methods from imported library, say MySQLdb in Sublime Text 2? 我需要做什么才能从导入的库中获取可用的方法,例如Sublime Text 2中的MySQLdb? In Pycharm, if I import a library, I get all the available methods from that library as suggestion like from Google search. 在Pycharm中,如果我导入一个库,则可以从该库中获取所有可用的方法,就像Google搜索一样。 But this is not the case in Sublime Text. 但这不是Sublime Text中的情况。 Is there any other plugin I have to install to get this feature? 我还需要安装其他插件才能获得此功能吗?

My best advice would be to upgrade to Sublime Text 3 and use Anaconda for code completion. 我最好的建议是升级到Sublime Text 3并使用Anaconda进行代码完成。 ST3 has a number of new features over ST2, and behind the scenes, the API has a bunch of changes that make writing and supporting plugins very easy - unfortunately, some of the changes are backwards-incompatible. ST3比ST2具有许多新功能,并且在幕后,API进行了大量更改,使编写和支持插件变得非常容易-不幸的是,某些更改是向后不兼容的。 ST2 includes Python 2.6 internally, while ST3 includes Python 3.3, so developers essentially either need to support two separate codebases, or have a lot of ugly if ST2: do this; else: do that ST2内部包含Python 2.6,而ST3内部包含Python 3.3,因此开发人员本质上要么需要支持两个单独的代码库,要么if ST2: do this; else: do that有很多丑陋之处if ST2: do this; else: do that if ST2: do this; else: do that type of constructs. if ST2: do this; else: do that构造。 The result of this is that a lot of plugin authors have chosen to only support ST3, meaning there are many more packages available for ST3 than ST2, and this includes Anaconda . 其结果是,许多插件作者选择仅支持ST3,这意味着ST3可用的软件包比ST2多,其中包括Anaconda The "beta" version of ST3 (currently build 3065) is just as stable as ST2. ST3的“ beta”版本(当前内部版本3065)与ST2一样稳定。 If you're a registered user (and you should be!), you have access to the bleeding-edge development builds (build 3081 was just released some hours ago), which have a ton of new features, but are sometimes less stable. 如果您是注册用户 (应该如此!),则可以使用最新的开发版本 (版本3081刚刚在几个小时前发布),该版本具有大量的新功能,但有时不稳定。 I've been using ST3 exclusively (unless I need to test something on ST2) for well over a year now, and haven't had any issues at all. 我已经专门使用ST3(除非我需要在ST2上进行测试),已经有一年多了,而且完全没有任何问题。

As far as Anaconda goes (it has no relation whatsoever with the Anaconda Python distribution), I just love it. Anaconda而言(它与Anaconda Python发行版没有任何关系),我只是喜欢它。 I used to use SublimeCodeIntel , but it was a little tough to configure, took a long time to index files, and oftentimes just didn't work well, if at all. 我曾经使用SublimeCodeIntel ,但是配置起来有点SublimeCodeIntel ,花了很长时间索引文件,而且有时根本无法正常工作。 Anaconda uses static analysis to figure out the type of your variables, and provides the appropriate methods and attributes via autocomplete. Anaconda使用静态分析来找出变量的类型,并通过自动完成功能提供适当的方法和属性。 All you need to do is specify where Python lives on your machine, and it will automatically configure itself to use the standard lib for that version, as well as any 3rd-party modules you may have installed. 您所需要做的就是指定Python在计算机上的位置,它将自动配置为使用该版本的标准库以及您可能已安装的任何第三方模块。 It can be configured independently via .sublime-project files, so you can use different interpreter versions depending on the project you're working on - it also works with virtualenvs. 可以通过.sublime-project文件独立配置它,因此您可以根据正在处理的项目使用不同的解释器版本-它也可以与virtualenvs一起使用。 Finally, it provides built-in linting via PEP8, PyLint, and/or PEP257, if you are so inclined (I just turn it off, as I think it's annoying, but it can be very helpful for novice coders). 最后,如果您愿意的话,它可以通过PEP8,PyLint和/或PEP257提供内置的棉绒(我觉得很烦,我将其关闭了,但对新手编码人员来说非常有用)。 Aside from the fact that it just works, Anaconda 's best feature is that it's entirely asynchronous, so it won't slow down ST3 or crash it if it has an unrecoverable error. 除了它可以正常工作外, Anaconda的最佳功能是它是完全异步的,因此,如果出现不可恢复的错误,它不会减慢ST3或使其崩溃。 I've never had it crash on me, through, another reason I like it. 我从来没有让它崩溃过,这是我喜欢它的另一个原因。

Finally, just in case you were wondering, I have no connection to the Anaconda project at all, other than a single pull request that removed one character - I'm just a very satisfied user. 最后,以防万一,您除了要删除一个字符的单个拉取请求外 ,根本没有与Anaconda项目建立任何连接-我只是一个非常满意的用户。

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

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