Showing posts from December, 2009

Vim: Replace tabs with spaces

When working in other peoples code I almost always notice mixed tabs and spaces. Like many programmers, this makes my skin crawl since it usually causes formatting to look horrible or incomprehensible.

First I'll double check that there are mixed tabs and spaces by highlighting the tabs.

If I see some whitespace highlighted and some not highlighted I'll look at the indentation and figure out how many spaces each tab should be, then do a replace. This will perform a replace on the entire file (%s) for all tabs (\t) into four spaces (\ \ \ \ ), the g at the end will allow the match to be done multiple times per line:
:%s/\t/\ \ \ \ /g

If your tab expand matches the file, you can also use the vim built-in retab:

Taking Stuff Apart: Data-Doc Data Switch

Not much to this one. The case is a nice size for a project box, which is why it was picked up in the first place. The mess of wires inside is impressive. As usual click the pictures for more (and in higher resolution).