Could you recommend, how to configure Vim to stick to :
PEP 8 -- Style Guide for Python Code
when editing python2/3 files, and only those (I'd like to leave configuration as it is for all other filetypes).
Could you recommend, how to configure Vim to stick to :
PEP 8 -- Style Guide for Python Code
when editing python2/3 files, and only those (I'd like to leave configuration as it is for all other filetypes).
As of 2014
Using syntastic plus installing
pip install flake8
gives you the best experience IMHO.syntastic
is great, because it not only does pep8 checks for Python, but by installing other software it's really easy to add syntax checks and the like for other languages.Oldest Answer (2012)
There's also a little script called 'pep8' - https://github.com/vim-scripts/pep8
I have it configured on 8:
I really like it. It works really good.
Old Answer (2013)
vim-flake8
is the better choice, I will try it :-)Here is a vimrc configuration file which I prefer to use. It takes care of all PEP8 configuration.
The answers are focusing on checking the style after source code has been written but the question seems to be about making vim stick to the pep8 style during editing itself.
The main problem I've had with vim and pep8 is indentation, which can be fixed using this vim script:
EDIT3: Fix the terrible English...
EDIT2: Whoops, wrong script! Fixed. http://www.vim.org/scripts/script.php?script_id=974
EDIT1:
The script has been forked on github:
https://github.com/hynek/vim-python-pep8-indent/
There's vim-flake8, which is most easily set up using vim-pathogen or Vundle.
I would recommend to use the inclusive klen/python-mode plugin.
Where you can use
:PymodeLintAuto
for PEP8 errors and warnings with every time you save your code.