Tip: Vim and python indentation

Posted on November 3, 2007
Filed Under python, tips, vim |

Usually I prefer tabs indentation rather than space indentation for python code. Unfortunately often python code from open source projects or code that you can find on the net use space indentation. To convert from one to the other you can simply use a vim substitution.

Example:

:%s/    /\t/g

It’s as simple as this :)

This will convert a four spaced indentation with a one tab one and make we happy :D

Comments

One Response to “Tip: Vim and python indentation”

  1. druss on November 19th, 2007 10:38 pm

    eeeeuuuw….i do it the other way around!

    also, Style Guide for Python Code prefers spaces to tabs:

    http://www.python.org/dev/peps/pep-0008/

    at the end of the day, each to their own…

Leave a Reply