Ⅰ. 插件描述
Find and yank Python import statement for keyword under cursor.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/tagport'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/tagport'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/tagport'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/tagport
Ⅳ. 文档说明
A simple script that finds the Python module using the keyword under the cursor and yank the import statement into the unnamed register "" so you can put it anywhere with the command 'p'.
Usage
- Move cursor to a word you'd like to import.
- Type
<Leader>fi - You'll be prompted with a list of import statements to yank into unnamed register
'"'. - Type a number.
- Put the import statement anywhere you like with
p. Tip: quickly jump back to last cursor position with `` (double backticks)
Options
let g:tagport_aliases = {}
There are times when importing from a different package is preferred as apposed to the actual Python module the class is defined.
For example, Django's Model is declared in django.db.models.base. However, it is a common practice that Model
is imported from django.db.models instead.
To do that, declare the following in .vimrc::
let g:tagport_aliases = {'django.db.models.base': 'django.db.models'}
The next time you search for Model, from django.db.models import Model is listed instead.
let g:tagport_ignore = []
models can be found in many places, but not all are useful. You can hide any entry with g:tagport_ignore.
For example, if you want to hide all models from migrations directory, declare the following in .vimrc::
let g:tagport_ignore = ['.migrations.']
Links:
1. README - http://bit.ly/xTL1qn
2. Screenshot - http://bit.ly/zqOfsv