By Vincent Driessen
on Tuesday, February 14, 2012

Just a quick post to let you know that I discarded my vim-pep8 and vim-pyflakes Vim plugins yesterday in favor of vim-flake8.

As you may know, PyFlakes is a static analysis tool that lets you catch static programming errors when you write them, not when you run into them at runtime. And pep8 is a Python style checking tool that enforces PEP8 guidelines on your code.

Flake8, though, seems to be a much better option to use these days. It integrates both of PEP8 and PyFlakes and even combines it with a cyclomatic complexity checker (which is irrelevant for the Vim plugin, by the way). To install Flake8, simply use:

$ pip install flake8

After installing the plugin in Vim, you can add the following command to your .vimrc file to have it executed after every save of a Python source file.

autocmd BufWritePost *.py call Flake8()

To avoid specific error messages from being reported, put a # noqa comment at the end of that line.


Assuming you already use vim-pathogen (which you really should), you can simply install the plugin by cloning the repository into the ~/.vim/bundle folder.

If you want to get in touch, I'm @nvie on Twitter.