Whitespace: Silent Killer!

Today I went hunting in an XML file for an erroneous double space I knew was there. 


I was horrified to see all those extra spaces there!!! Now this Visual Studio 2010 instance is just running the default setup with the productivity tools installed (Oh and I hit Ctrl+R, Ctrl+W to show the whitespace characters used)


That’s an 81KB XML file!

Now I’m a believer in tabs over spaces and full tab sized indents in all cases, to me it’s cleaner and reduces page weight.

So, open up Visual Studios options, Tools > Options and go to Text Editor > All Languages > Tabs. For me this is what I found….


Settings that were not consistent across all the file types and Spaces used as indents! Grrrr!!!!! So, a quick change of settings:


A quick Ctrl+A, Ctrl+K, Ctrl+F to re-format the file and things looks much tidier:


The file size came down to 80KB, so about a 1.25% savings, not a huge amount, but if you think about that over all of the code sitting in source control for a development company like ours that’s likely to be gigabytes worth of savings. Plus the double space in the file stood out nice and clearly!

Now that the preferences for VS are ‘fixed’ all of the files will get the ugly space based whitespace removed as they get worked on.


This entry was posted in Deployment, Visual Studio. Bookmark the permalink.

4 Responses to Whitespace: Silent Killer!

  1. Tabs! NOOOOOOOOO, spaces FTW. They look consistent on all platforms/dev tools

    • gavinbarron says:

      The key really is a consistent approach across your solution. Which was one of the things that I noticed in VS, not all file types had the same settings.
      Spaces vs. Tabs: Tabs every time for this guy, I work in a single environment.
      If you’re working in a dev environment that doesn’t handle tabs WTF? Even notepad does tabs consistently…. (note consistently)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.