Since I maintain a lot of code that wasn't originally written by me, I am in the unfortunate situation that I get to edit code with many different coding and indentation styles on a regular basis. Reformatting usually isn't a good idea since not only may the original author object, but the revision control history is more important than code and indentation style.

I'm a vi(m) user. Modifying the settings to suit whatever insane tab-compression-indentation scheme some crazy emacs user decided on for individual documents is severely annoying. My editor should do this for me. If I was using Padre for my daily work, it would do this for me automatically. Today, finally, I sat down and wrangled vi until it would auto-detect the indentation style of the current document. More precisely, Text::FindIndent does (version 0.09 was just released and is required). Install the module, include this in your .vimrc on one line:

map <F5> <Esc> :perl use Text::FindIndent;VIM::DoCommand($_) for Text::FindIndent->to_vim_commands(join "

", $curbuf->Get(1..$curbuf->Count()));<CR>

Now, open up somebody else's source code that uses some crazy indentation scheme. Hit F5. Your vi settings have now been marvelously modified to produce the same broken indentation as whatever you opened for editing.