Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim and PEP 8 -- Style Guide for Python Code

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).

like image 563
Grzegorz Wierzowiecki Avatar asked Mar 25 '12 22:03

Grzegorz Wierzowiecki


People also ask

What is PEP 8 -- Style Guide for Python code?

PEP 8, sometimes spelled PEP8 or PEP-8, is a document that provides guidelines and best practices on how to write Python code. It was written in 2001 by Guido van Rossum, Barry Warsaw, and Nick Coghlan. The primary focus of PEP 8 is to improve the readability and consistency of Python code.

Can you use Vim for Python?

Using Vim as a Python IDEThe python-mode project is a Vim plugin with syntax highlighting, breakpoints, PEP8 linting, code completion and many other features you'd expect from an integrated development environment.

What is PEP series in Python?

PEP stands for Python Enhancement Proposal. A PEP is a design document providing information to the Python community, or describing a new feature for Python or its processes or environment.


2 Answers

As 2020

Using ale plus installing a linter pip3 install pylint is asynchronous and therefore probably the better idea. It does not block when you save, syntastic will block. It also works for other languages (like syntastic). It is based on the Language Server Protocol.


Old Answer (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.

Old Answer (2013)

vim-flake8 is the better choice, I will try it :-)

Oldest Answer (2012)

There's also a little script called 'pep8' - https://github.com/vim-scripts/pep8

I have it configured on 8:

let g:pep8_map='<leader>8' 

I really like it. It works really good.

like image 168
Dave Halter Avatar answered Oct 09 '22 01:10

Dave Halter


There's vim-flake8, which is most easily set up using vim-pathogen or Vundle.

like image 25
Niklas B. Avatar answered Oct 09 '22 02:10

Niklas B.