461

How can Sublime Text show non printable characters (I'm interested in SPACEs and TABs)?

imkost
  • 8,033
  • 7
  • 29
  • 47

11 Answers11

694

To view whitespace the setting is:

// Set to "none" to turn off drawing white space, "selection" to draw only the
// white space within the selection, and "all" to draw all white space
"draw_white_space": "selection",

You can see it if you go into Preferences->Settings Default. If you edit your user settings (Preferences->Settings - User) and add the line as per below, you should get what you want:

{
    "color_scheme": "Packages/Color Scheme - Default/Slush & Poppies.tmTheme",
    "font_size": 10,
    "draw_white_space": "all"
}

Remember the settings are JSON so no trailing commas.

Andrew Barrett
  • 19,721
  • 4
  • 47
  • 52
  • 2
    Is there any way to change the color of white space (dash for tabs) to a little more light? – Mithun Sreedharan Feb 15 '13 at 13:20
  • 3
    @Mithun you should be able to edit the colour scheme to make that change. I'm not sure of the specific colour setting you would have to change, but they are labelled pretty sensibly so you should be able to find it with a bit of playing around. – Andrew Barrett Feb 18 '13 at 10:06
  • 3
    At the beginning of a color scheme, you'll find general settings — background, caret, foreground, etc. The "invisibles" key is the color you want to change. – Roger_S Aug 26 '13 at 15:35
  • 2
    why not remove the color scheme stuff? thanks and upvote anyway! :D – HaveAGuess Jul 16 '15 at 08:15
  • 18
    There's no way to just toggle this from a menu?? Even the simplest text editors have this "feature". – Ciri Nov 26 '15 at 11:22
  • By the way, as of Sublime Text 3 (or perhaps even newer versions of ST2), you *can* have trailing commas. Makes things easier. – Kat Mar 21 '16 at 15:42
95

In selected text, Space is shown as a middle dot (·) and Tab as a long dash ().

Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
Pavel Hodek
  • 14,319
  • 3
  • 32
  • 37
17

I use Unicode Character Highlighter, can show whitespaces and some other special characters.

Add this by, Package Control

Install packages, unicode ...

staticor
  • 620
  • 9
  • 19
  • It will show up automatically if it finds some of special characters it can detects. – 5ulo Feb 20 '14 at 20:53
14

If you really only want to see trailing spaces, this ST2 plugin will do the trick: https://github.com/SublimeText/TrailingSpaces

thomax
  • 9,213
  • 3
  • 49
  • 68
13

If you want to be able to toggle the display of whitespaces on and off, you can install the HighlightWhitespaces plugin

chiborg
  • 26,978
  • 14
  • 97
  • 115
12

Here is an Official tutorial of how to do that!
http://sublimetexttips.com/show-whitespace-sublime-text/

just like this!

enter image description here
enter image description here

Hope help for you!

xgqfrms
  • 10,077
  • 1
  • 69
  • 68
4

I know this is an old thread, but I like my own plugin that can cycle through whitespace modes (none, selection, and all) via a single shortcut. It also provides menu items under a View | Whitespace menu.

Hopefully people will find this useful - it is used by a lot of people :)

halfer
  • 19,824
  • 17
  • 99
  • 186
kodybrown
  • 2,337
  • 26
  • 22
  • This _might_ be regarded as a link-only answer, or a response to a software recommendation, both of which are off-topic. However, it does seem to be helpful, so I'll leave it be `:-)`. – halfer Mar 08 '16 at 20:23
3

A "quick and dirty" way is to use the find function and activate regular expressions.

Then just search for : \s for highlighting spaces \t for tabs \n for new-lines etc.

Damocles
  • 39
  • 1
2

http://sublimetexttips.com/show-whitespace-sublime-text/

  1. open

Ctrl+Shift+P

  1. search

Preferences: Settings –> User

  1. just paste below codes

{
    "draw_white_space": "all",
    "translate_tabs_to_spaces": true
}
1

I've several plugins (including Unicode Character Highlighter), but the only one which found the character that was hiding from me today was Highlighter.

You can test to see if it's working by pasting in the text from the readme.

For reference, the character causing me trouble was .

For a sanity check, tap your right arrow key over a range of text containing an invisible character, and you'll need to right-arrow twice to move past the character.

I'm also using the following custom regex string (which I don't fully grok):

{
    // there's an extra range in use [^\\x00-\\x7F]
    // also, don't highlight spaces at the end of the line (my settings take care of that)
    "highlighter_regex": "(\t+ +)|( +\t+)|[^\\x00-\\x7F]|[\u2026\u2018\u2019\u201c\u201d\u2013\u2014]"
}
ptim
  • 14,902
  • 10
  • 83
  • 103
  • btw.. this character was copied out of a Skitch > Zeplin workflow – ptim Jul 18 '16 at 06:38
  • ...and whilst I think of it, as another sanity check is http://linux.die.net/man/1/xxd. On the terminal, type `xxd`, enter, then paste your string – ptim Jul 18 '16 at 07:07
0
  1. Open the preferences settings(Command+,)
  2. Add "draw_white_space": "add"

settings

Eazow
  • 21
  • 3