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

后端 未结 4 1045
一整个雨季
一整个雨季 2021-02-20 11:59

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?

相关标签:
4条回答
  • 2021-02-20 12:41

    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.

    0 讨论(0)
  • 2021-02-20 12:55

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

    0 讨论(0)
  • 2021-02-20 12:56

    A few years later, I was struggling with this in Sublime Text 3 build 3083. I hope this helps anyone. In addition to Chris Like's suggestion to install PersistentRegexHighlight and setting "draw_white_space": "all" in the user preferences and the pattern to one or more occurances of tabs and spaces, i.e. [ \t]+ in the PersistentRegexHighlight user settings, i had to also also set "color_scope": "highlight.whitespace" and add the following dict to the theme along with the other ones in the settings array:

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

    which by the way oddly only outlines in red if the background is set to black, i.e #000000

    Note that this method does not require editing any syntax files.

    0 讨论(0)
  • 2021-02-20 13:03

    You can change the tab underline alpha by changing the foreground alpha.

    To change the color of spaces requires changes to every syntax file.

    0 讨论(0)
提交回复
热议问题