vim-isort


Ⅰ. 插件描述

Vim plugin to sort python imports using https://github.com/timothycrosley/isort

Ⅱ. 基本信息

创建日期:  2013-10-02
使用用户:  459
Github星:  172
插件作者:  Juan Pedro Fisanotti

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

vim-isort

Vim plugin to sort python imports using isort <https://github.com/timothycrosley/isort>_

Usage

Just call the :Isort command, and it will reorder the imports of the current python file.
Or select a block of imports with visual mode, and press Ctrl-i to sort them.

You can also configure isort options, check them on the isort docs <https://github.com/timothycrosley/isort>_.

Installation

  • Install isort <https://github.com/timothycrosley/isort>_:

.. code::

pip install isort
  • Add the plugin to vim using Vundle <https://github.com/gmarik/vundle>_ or any other plugin manager, pointing to this repo:

.. code::

Plugin 'fisadev/vim-isort'

(Or if you don't use any plugin manager, you can just copy the python_vimisort.vim file to your .vim/ftplugin folder)

Configuration

You can configure the default mapping for the visual mode sorter, like this:

.. code-block:: viml

let g:vim_isort_map = '<C-i>'

Or disable the mapping with this:

.. code-block:: viml

let g:vim_isort_map = ''

You can configure overrides for isort's config parameters:

.. code-block:: viml

let g:vim_isort_config_overrides = {
  \ 'include_trailing_comma': 1, 'multi_line_output': 3}

You can also specify a particular Python version, so if isort is installed under Python 3:

.. code-block:: viml

let g:vim_isort_python_version = 'python3'

添加新评论