Friday, July 23, 2010

Converting Between Tabs and Spaces

If you want to use tabs in Python but everyone else uses spaces, here's something helpful you can do in git!

% echo '*.py filter=tabspace' >> .git/info/attributes
% git config --global filter.tabspace.smudge 'unexpand --tabs=4 --first-only'
% git config --global filter.tabspace.clean 'expand --tabs=4 --initial'

You can appear to comply with PEP-8 to others using your repository, but you don't need to change your habits!