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. and insert the following contents:


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


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


Re: Strip Trailing Whitespace in Xcode 4

No posts

This topic is archived. No further replies will be accepted.




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