Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 2: how to change white space characters color?

The color seems to be linked to the foreground in themes. I assume it's using less alpha. Is there a way to control this?

like image 557
Rui Nunes Avatar asked Nov 08 '12 20:11

Rui Nunes


People also ask

Why is my Sublime Text white?

This happens when Sublime Text doesn't know which syntax highlighting to choose. First of all Sublime Text guesses the syntax from the file extension. E.g. if you have a file named my_file_name. php Sublime Text assumes that the PHP syntax highlighting is the best.

How do I change the selection color in Sublime Text?

Changing the selection colour in Sublime Text 3. Open the command palette with ⌘+⇧+P on mac iOS (for windows/linux Ctrl + Shif + P) and type prv to get the PackageResourceViewer options. Choose Open Resource >> Color Scheme – Default >> and choose your theme file to edit.


2 Answers

There's now a Sublime plugin for this.

  1. Install the HighlightWhitespaces plugin

  2. Add the following color settings (tailored to your preference) to your color_scheme file. This file ends in .tmTheme and the path can be found by looking at the value for the key "color_scheme" in your settings file.

    <dict>
      <key>name</key>
      <string>highlight.whitespace</string>
      <key>scope</key>
      <string>highlight.whitespace</string>
      <key>settings</key>
      <dict>
        <key>background</key>
        <string>#020202</string>
        <key>foreground</key>
        <string>#805050</string>
      </dict>
    </dict>
    
  3. Specify that this color should be used by adding the following to the user settings of the HighlightWhitespaces plugin:

    {
        "highlight_whitespaces_space_highlight_scope_name": "highlight.whitespace",
        "highlight_whitespaces_tab_highlight_scope_name": "highlight.whitespace",
        "highlight_whitespaces_eol_highlight_scope_name": "highlight.whitespace",
        "highlight_whitespaces_mixed_highlight_scope_name": "highlight.whitespace"
    }
    
  4. Relax and enjoy :-)

like image 85
jimr Avatar answered Oct 12 '22 19:10

jimr


You may want to try installing PersistentRegexHighlight from Package Control and then use a blank-character regex like [\x20 ] to add a specific color or color scope.

You'd want to combine this with drawWhiteSpace: "all", in Sublime user prefs.

like image 45
Chris Like Avatar answered Oct 12 '22 18:10

Chris Like