Auto在vim / emacs中包含python import语句? [英] Auto Include python import statements in vim /emacs?

查看:129
本文介绍了Auto在vim / emacs中包含python import语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在eclipse中,有一个方便的缩写CTRL + SHIFT + o,它将根据所使用的类或模块自动包含所需的import(include)语句。
你有没有发现任何这样的vim或emacs插件?

解决方案

Ropemacs rope-auto-import ,所以如果你写

 code> rmtree 

并执行 Mx rope-auto-import

 从shutil import rmtree 

插入文件的顶部。您可能希望避免这种情况,因为从模块导入函数可能不是一个非常明智的想法。



请参阅此SO文章,以获取有关设置ropemacs的信息。
ropemacs附带的README(例如/usr/share/doc/python-ropemacs/README.txt.gz)也有用于设置ropemacs-auto-import命令使用的缓存的有用信息。 p>

In eclipse, there is this handy shorthand CTRL+SHIFT+o which will auto include the import (include) statements which are needed based on the Class or module being used. Have you found any such plugin for vim or emacs?

解决方案

Ropemacs has rope-auto-import, so that if you write

rmtree

and execute M-x rope-auto-import,

from shutil import rmtree

is inserted at the top of the file. You might want to avoid this though, because importing functions from modules may not be a very wise idea.

See this SO post for information on setting up ropemacs. The README (e.g. /usr/share/doc/python-ropemacs/README.txt.gz) that comes with ropemacs also has useful information for setting up the cache used by the ropemacs-auto-import command.

这篇关于Auto在vim / emacs中包含python import语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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