是否有一个插件vim来自动导入python库? [英] Is there a plugin for vim to auto-import python libraries?

查看:752
本文介绍了是否有一个插件vim来自动导入python库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在eclipse中,您可以按Ctrl + Shift + o自动导入您在代码中引用的所有库。有什么类似的vim插件可以使用python吗?

In eclipse you can hit Ctrl+Shift+o to automatically import all the libraries you reference in your code. Is there any similar plugin for vim to have this feature with python?

推荐答案

pypi 上获得

自动导入(添加缺少导入)和组织导入(重新排序导入)功能工作正常,但它有时会有一点侵入(它将在您的项目中创建一个.ropeproject文件夹)。绳索代码完成也很好,所以我使用标签代码完成,当它不够,我使用ctrl-space来使用ropevim自动完成。

The autoimport (adds missing imports) and organizeimport (reorder imports) features work well, but it is a little invasive at times (it will create a .ropeproject folder in your project). Rope code completion is also quite good so I use standard code completion with tab, and when it's not enough, I use ctrl-space to use ropevim autocompletion.

这里有一些使用ropevim进行映射:

Here are some of my mappings with ropevim:

" Rope AutoImport and OrganizeImport
nnoremap <C-S-o> :RopeOrganizeImports<CR>0<CR><CR>
nnoremap <C-S-i> :RopeAutoImport<CR>

" Rope AutoComplete
let ropevim_vim_completion = 1
let ropevim_extended_complete = 1
let g:ropevim_autoimport_modules = ["os.*","traceback","django.*","lxml.etree","lxml.*"]
imap <c-space> <C-R>=RopeCodeAssistInsertMode()<CR>

" Rope Menu
menu Python.Create\ Package :RopeCreatePackage<CR>
menu Python.Create\ Module :RopeCreateModule<CR>

这篇关于是否有一个插件vim来自动导入python库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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