68

I want the tabs and spaces to be visible in Xcode. Is this possible? I can't find it under preferences.

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178

7 Answers7

102

Editor -> Show Invisibles in Xcode 4

gregschlom
  • 4,825
  • 4
  • 28
  • 23
  • 5
    @JavierSedano I've checked around, and it seems there is no reasonable way to achieve what you're asking as of this writing. This is because common characters such as brackets are coupled to the same font color setting as invisibles. – AWrightIV Sep 26 '12 at 07:34
  • I suggest Apple moves settings to the settings pane. Else it's Microsoft or Google. – Anticro Dec 29 '21 at 11:06
55

In Xcode 7 and later, this command has moved to the Editor menu:

Editor > Show Invisibles

or

Editor > Hide Invisible

Edit

As of Xcode 12.1, the menu item is now simply called Invisibles. It's checked when invisibles are shown, and un-checked when they are not shown.

Further, it looks like Xcode now uses very light blue dots for spaces, and bold light blue dots for the spaces that correspond to your tab positions, which is very nice.

Community
  • 1
  • 1
Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • 6
    Is it possible to change the characters used to represent the whitespaces and tabs ? Visual studio uses a simple dot which is more viewable than the one used by xcode. – user3279954 Mar 07 '17 at 20:21
  • I don't know. Sorry. – Duncan C Mar 06 '19 at 00:22
  • 1
    It looks like newer versions of Xcode use a dot for spaces now (I'm running Xcode 12.1 and spaces show as dots, with every 4th space {when using 4-character space-based indentation} is bold.) – Duncan C Feb 22 '21 at 14:09
32

You can also use defaults to read/write to the Xcode plist

This is used/tested in Xcode 6.1

GUI

Editor->Show Invisibles

CLI

Turn it on

defaults write com.apple.dt.Xcode DVTTextShowInvisibleCharacters 1

Turn it off

defaults write com.apple.dt.Xcode DVTTextShowInvisibleCharacters 0
pkamb
  • 33,281
  • 23
  • 160
  • 191
Jason Jarrett
  • 3,857
  • 1
  • 27
  • 28
18

Since Xcode 11:

In the menu check/uncheck: Editor -> Invisibles

dab0bby
  • 2,951
  • 1
  • 31
  • 35
18

It is under Editor -> Invisibles. You can check it to show or uncheck it to hide them.


A note about the macOS 

In the mac environment, you can search for any menu option under the Help menu, then it will open the exact menu path you are looking for. For example, searching for invisibles results in this:

Demo

Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
14

In Xcode 6.x and earlier:

View -> Text -> Show Spaces

View -> Text -> Show Control Characters

Duncan C
  • 128,072
  • 22
  • 173
  • 272
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
  • 4
    Thanks. That does show the spaces. Oddly Show control characters is not making the tabs visible. And seeing how XCode shows spaces I may reconsider my desire to use this. :-( –  May 17 '09 at 02:25
  • 27
    I⌴agree,⌴it's⌴annoying⌴to⌴read⌴through⌴your⌴code⌴thinking⌴that⌴your⌴font⌴may⌴be⌴missing⌴some⌴characters… – Vince Dec 06 '11 at 11:11
  • For Xcode 13 beta 2: Editor -> Invisibles – Lee-der Jul 09 '21 at 16:21
2

You can also enter a white space into the search field, this will highlight all white spaces in yellow temporarily. I found this accidentally here, where Marty asked the other way around: What are these yellow spacers in Xcode?

Community
  • 1
  • 1
lukas_o
  • 3,776
  • 4
  • 34
  • 50
  • Won't that only match the specific TYPE of whitespace you're searching for? (spaces or tabs or non-breaking spaces, but never all different kinds of white-space) – Duncan C Nov 29 '17 at 16:35
  • 1
    ...although you could create a regular expression search that would find all different kinds of whitespace.. – Duncan C Mar 26 '18 at 19:43