Checking Python files with Vim

Vim is an excellent editor, and mastering it leads to more productivity. Even though is very extensible and allows to be configured by many plug-ins I rather keep it as simple as possible, trying not to use many plug-ins (neither packagers like Vundle, etc.).

However, I do make use of an extension that checks Python files for errors, PEP8, among other things: flake8. Because I do not use plug-in platforms for Vim, I install just this one manually, by making the command flake8 available system-wide 1.

Then the installation is as simple as downloading the project and coying the files into the ~/.vim/ft­plug­in/python directory. Make sure you have the following line added on your ~/.vim­rc:

filetype plugin indent on

The features I use are mainly the syntax and PEP-8 compliance checkers. It can also warn you about unused imports, and cyclomatic complexity.

It is useful because things like PEP-8 compliance help to have a good code quality, and therefore a more readable and maintainable code base, specially on large projects with lots of files and modules.

That’s al­l. For more de­tails and oth­er con­fig­u­ra­tion tips check­out my Vim set­up.


An­oth­er op­tion would be to in­stall it on your vir­tu­al en­vi­ron­men­t, but then you have to make sure to in­stall it once per projec­t. It is ac­tu­al­ly bet­ter, be­cause you are not us­ing the glob­al sys­tem en­vi­ron­men­t, but for pack­ages like this, it should not be an is­sue, it’s your choice.