Search code examples
pythonvimvim-plugin

How to change vim Python indent size?


I have set tabstop and shiftwidth to 2 in my vimrc, but still when I go to a new line vim uses 4-space indents. I also get this warning if I save a file that uses 2 spaces for indentation:

E111 indentation is not a multiple of four [pep8]

How can I make vim use 2 spaces for Python? It seems to be ignoring my vimrc for Python.

I am using vim 7.2.


Solution

  • Whitespace is an integral part of the Python language, and four spaces is the mandate. You could, however, use only shifts and have your editor read a shift as only two spaces, but I would not recommend this. This could easily cause problems with mixing spaces and tabs, which can cause a giant hassle.