Vim plugin to sort python imports using https://github.com/timothycrosley/isort
Vim script
Latest commit 65bd9fe Mar 12, 2017 @fisadev committed on GitHub Merge pull request #16 from Matt-Deacalion/master
Add ability to specify Python version
Permalink
Failed to load latest commit information.
ftplugin Add ability to specify Python version Feb 22, 2017
.gitignore Added .gitignore Oct 2, 2013
README.rst Add ability to specify Python version Feb 22, 2017

README.rst

vim-isort

Vim plugin to sort python imports using 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.

Installation

pip install isort
  • Add the plugin to vim using Vundle or any other plugin manager, pointing to this repo:
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:

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

Or disable the mapping with this:

let g:vim_isort_map = ''

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

let g:vim_isort_python_version = 'python3'