Wednesday, July 14, 2010

Fixing Python indentations in VIM

Had this problem today where I created a file with eclipse then edited it with vim and that made the tabs inconsistent. Found this post on stackoverflow that had a couple of suggestions

http://stackoverflow.com/questions/1024435/howto-fix-python-indentation

1. Use reindent.py - this requires apt-get install python-examples on debian/ubuntu
2. :%s/\t/ /g - this is what I used and it worked great

Other vim tricks I have used lately:
- Remove empty lines :%s/^[\ \t]*\n//g
- Re-indent entire file gg=G
- Remove lines with comments g/^#/d

No comments: