python-imports.vim


Ⅰ. 插件描述

Vim plugin that adds Python import statements semi-automatically

Ⅱ. 基本信息

创建日期:  2013-03-14
使用用户:  8
Github星:  22
插件作者:  Marius Gedminas

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'mgedmin/python-imports-vim-red'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'mgedmin/python-imports-vim-red'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'mgedmin/python-imports-vim-red'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/mgedmin/python-imports.vim

Ⅳ. 文档说明

Overview

Vim script to help adding import statements in Python modules.

You need to have a tags file built (:!ctags -R ., be sure to use
exuberant-ctags <http://ctags.sourceforge.net/>_ or `Universal
Ctags https://ctags.io/_). You can use Gutentags
https://github.com/ludovicchabant/vim-gutentags`__ plugin for
automatic tags management.

Type :ImportName [<name>] to add an import statement at the top of the file.

Type :ImportNameHere [<name>] to add an import statement above the current
line.

I use the following mappings to import the name under cursor with a single
keystroke::

map <F5> :ImportName<CR>
map <C-F5> :ImportNameHere<CR>

Needs Vim 7.0, preferably built with Python support.

Tested on Linux only.

Installation

I recommend Vundle <https://github.com/gmarik/vundle>_, `pathogen
https://github.com/tpope/vim-pathogen_ or Vim Addon Manager
https://github.com/MarcWeber/vim-addon-manager`_. E.g. with Vundle do ::

:BundleInstall "mgedmin/python-imports.vim"

Manual installation: copy plugin/python-imports.vim to ~/.vim/plugin/.

Configuration

In addition to the tags file (and builtin logic for recognizing standard
library modules), you can define your favourite imports in a file called
~/.vim/python-imports.cfg. That file should contain Python import
statements like ::

import module1, module2
from package.module import name1, name2

Continuation lines are not supported. Parenthesized name lists are partially
supported, if you use one name per line, i.e. ::

from package.module import (
    name1,
    name2,
)

Copyright

python-imports.vim was written by Marius Gedminas <marius@gedmin.as>.
Licence: MIT.

添加新评论