shibly shibly -4 years ago 88
Python Question

How can i get correct indentation in gvim for python?

I'm using a python library. I don't know about the indentation that the writer of that file used.

With gvim i press

o
and start writing python as
indent on
in .vimrc.

But if i copy and paste python code in pastebin.com i see indentation difference and get error.

How can i fix python indentation problem in gvim?

Answer Source

Very likely, your source file contains both tabs and spaces.
spaces are the preferred indentation method. (From PEP8)
You can convert all tabs to spaces by using those command:

:set expandtab
:ret!

I suggest put those commands bellow in your .vimrc:

set expandtab softtabstop=4 tabstop=4 shiftwidth=4
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download