ChatGPT解决这个技术问题 Extra ChatGPT

Sublime Text 2 - View whitespace characters

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


A
Andrew Barrett

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.


Is there any way to change the color of white space (dash for tabs) to a little more light?
@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.
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.
why not remove the color scheme stuff? thanks and upvote anyway! :D
There's no way to just toggle this from a menu?? Even the simplest text editors have this "feature".
G
Gabriel Staples

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


unless you've set '"translate_tabs_to_spaces": true' ofcourse
Which of course makes Ctrl/Cmd+A the fastest way of checking whitespace problems.
This works on my linux laptop but doesn't on my windows desktop.
This is SO useful and easy to see! Just press Ctrl + A to select everything, and voilá! You magically see all the tab and space chars as you described!
Note that this also works in Sublime Text 3 and 4.
s
staticor

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

Add this by, Package Control

Install packages, unicode ...


It will show up automatically if it finds some of special characters it can detects.
t
thomax

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


pylinter will also do this.
I love these little plugins. Super-alt-w highlights spaces in pink. Thanks!
c
chiborg

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


This feature was added in TrailingSpaces as well (just to note).
Works fine in Sublime 3, too. Toggle the Whitespace view with Control-Alt-W.
x
xgqfrms

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

just like this!

https://i.stack.imgur.com/q2R8q.png

Hope help for you!


h
halfer

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 :)


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 :-).
D
Damocles

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.


Actually "\s" is for all whitespace. For space only, escape the space character, "\ "
佚名

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

open

Ctrl+Shift+P

search

Preferences: Settings –> User

just paste below codes

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


p
ptim

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]"
}

btw.. this character was copied out of a Skitch > Zeplin workflow
...and whilst I think of it, as another sanity check is linux.die.net/man/1/xxd. On the terminal, type xxd, enter, then paste your string