Ⅰ. 插件描述
Simple vim plugin that guesses an import path based on a tags fileⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'mjbrownie/python-tag-import'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'mjbrownie/python-tag-import'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'mjbrownie/python-tag-import'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/mjbrownie/python-tag-import
Ⅳ. 文档说明
(Note this plugin is superceded by rope.vim).
repo: http://github.com/mjbrownie/Python-Tag-Import/tree/master. bugs/suggestions welcome
visual example here http://ttyshare.com/rec/michael/77604285/
This is for when you remember the name of a library function/class but not the module.path it is under
Eg. on a new line type. (control-b in insert mode is the default key but can be changed. see below)
funcname<c-b>
to get complete import options eg
from foo.bar.module import funcname
import foo.bar.module as module
etc.
In normal mode <leader>i will create an import for the current word
You can customise the import statements to your style preferences in your .vimrc eg
let g:pythontagimport_from = 0
turns off
from foo.bar.module import funcname
let g:pythontagimport_from_mod = 0
turns off
from foo.bar import module #module.funcname
let g:pythontagimport_as = 0
turns off
import foo.bar.module as module #module.funcname
let g:pythontagimport_full = 0
turns off
import foo.bar.module #foo.bar.module.funcname
" Usage:
"
" You need a ctags file with the --fields=+i
" option set
"
" on a new line type the function you want to import
" then hit the complete key
"
" eg. type on a line
"
" some_func
" hit <c-b>in insert mode and get
" from some.app.module.path import some_func
"
" hotkey:
" insert mode map.
" <c-b> is the current default.
"
" variables:
"
" g:pythontagimportkey
" the key used to complete function
" parameters and key words.
"
"Limitations:
"
" This plugin is only as smart as your tags file.
" Completion is created through inspecting the filename
" in the tags file so functions that are rereferenced will not be
" picked up. I put this out there in the hope someone can do
" some fancy introspective alternative.
"
"Options:
" Setting the path can keep options relevant. At tht moment
" it defaults to sys.path. It can come up with some bad guesses
" Eg.
" let g:python_path = ['/usr/lib/python2.4/site-packages/']