Because I wanted to do some things with the Twitter API, lately I started using Python a bit more again. One cause for major headaches when working with Python is the issue of source files mixing tabs and spaces.

Personally, I always like to set up a tabstop and shiftwidth of 4 in my ViM session and expand all tabs to spaces. I achieve this by using these settings in my .vimrc:

set tabstop=4 set shiftwidth=4 set expandtab
Before, when I opened a file that had mixed tabs and spaces, I always used a find-and-replace approach to change all tabs into spaces. However, yesterday I found out that a much easier approach exists in ViM (as usually… ![;)](http://www.guidodiepen.nl/wp-includes/images/smilies/icon_wink.gif) ), namely by using the :retab command. After opening a file that has mixed tabs and spaces, using the :retab command will actually reformat the current buffer based on the setting of expandtab.

Always happy when I find these little gems that make my life easier :)