andviro / flake8-vim

Pyflakes, Pep8 and mccabe code complexity checker for Vim, bundled with latest libraries for easy installation
63 stars 18 forks source link

Running PyFlakeAuto on the entire file? #18

Closed dzackgarza closed 9 years ago

dzackgarza commented 9 years ago

Hello -- first of all, thanks for the amazing plugin, I love it so far!

I just had a quick note/question. If I select the entire file in visual mode and run PyFlakeAuto, it doesn't seem to auto-correct everything. In my case, it simply fix whitespace errors like adding extra blank lines or removing trailing whitespace. Is there a config that changes this?

I was also wondering if there is a way to run the same command whenever a python buffer is saved. Thanks again for making such a great plugin!

andviro commented 9 years ago

Hello! Thanks for the kind words, it's a pleasure to help fellow Pythoneers. The autocorrection works non-aggressively, it removes redundant whitespace, auto-indents where applicable and fixes multiple imports: import math, socket becomes import math import socket

BTW if you run PyFlakeAuto without range, it will work on entire file. You can put it into your .vimrc like:

augroup MyPython au BufWritePre *.py PyFlakeAuto augroup end As for auto-correction config options, I'll try to find time and revisit it, but not very soon 'cause there are other pressures at the moment.