Strip Trailing Whitespace in Xcode 4
Tuesday, November 01, 2011, by Sebastian Dwornik

XCode 4 is great.  But it has some annoyances.  One of which is inserting whitespaces in your code as if they were breadcrumbs to mark your path in case you get lost.

Thanks to Brian Cardarella for originally working this out, I simply modified his script to handle *.h and *.m files.

Simply create your own shell script  (e.g. stripWhitespace.sh) and insert the following contents:

#!/bin/sh

find . -name "*.[hm]" -type f -print0 | xargs -0 sed -i '' "s/[[:space:]]*$//"


Lastly set a 'Behavior' in XCode to run the script with a shortcut.

strip whitespace in XCode

Voila!

It will clear all of the whitespace within your entire projects directory for all files ending in *.h and *.m .

Enjoy!

 

Welcome to my App World

My name is Sebastian Dwornik and I am an entrepreneur located near Toronto, Canada.

Here you will find my thoughts on all matters regarding software, design, business, and sometimes life in general.

Have feedback? Don’t be shy and post your comments within the forum.


CONNECT WITH US

Twitter Facebook
Linkedin Rss

profile for Sebastian Dwornik at Stack Overflow, Q&A for professional and enthusiast programmers

Categories
Archives

April (1)
March (1)
February (2)
January (2)

Past archives (2011)

Past archives (2010)

Past archives (2009)

Past archives (2008)

 
 
Copyright © 2007 - 2012 Applied PDA Software, Inc. Fresh Lime Studio
All products mentioned on this web site are owned and copyrighted by their respective companies.