Trim trailing spaces in Xcode

Alexander Gladysh picture Alexander Gladysh · Sep 7, 2009 · Viewed 37.7k times · Source

Is there a way to force Xcode to trim trailing whitespaces when I save file?

I'm using version 3.1.3 if that matters.

Answer

Martin Stolz picture Martin Stolz · Aug 6, 2012

Starting from Xcode 4.4 whitespaces will be trimmed automatically by default, unless the line is all whitespace. You can also activate Including whitespace-only lines to fix this, which is not active by default.

Go to Xcode > Preferences > Text Editing > While editing

Xcode preferences screenshot