Sublime Text 2:如何更改空格字符的颜色?

11

主题中颜色似乎与前景相关联。我猜它使用了更少的 alpha(透明度)。是否有一种方法来控制这个?

4个回答

4
现在有一个适用于Sublime的插件。
  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 :-)


主题文件在哪里? - fechidal89
@fechidal89:现在回顾我的答案,第二点应该说“将颜色设置添加到您的颜色方案文件中”。因此,转到菜单“首选项->设置”并查看与“color_scheme”相关联的值(令人困惑的是,文件名以.tmTheme结尾),应该在此文件中添加颜色设置。 转到菜单“首选项->浏览程序包”以打开程序包文件夹,“color_scheme”路径将指向此文件夹下的一个文件。 对于我来说,它是:“color_scheme”:“Packages / User / SublimeLinter / Monokai-Dev(SL)Jim's edit.tmTheme” - jimr
对于Sublime 3,颜色存储在不同的位置。对于Mac OS,它存储在/Applications/Sublime Text.app/Contents/MacOS/Packages下的Color Scheme - Default.sublime-package文件名中。 出于安全原因,您需要将该文件复制到其他地方,解压缩它,编辑它,备份原始文件并替换为您编辑过的文件。 - Ari R. Fikri
jimr,你的第二项中,“background”和“foreground”的区别是什么?能否制作屏幕截图,让用户看到不同之处?这些键可能表示类似的行为。谢谢。 - Саша Черных

3

您可能想尝试从“Package Control”安装PersistentRegexHighlight,然后使用空格正则表达式[\x20 ]来添加特定的颜色或颜色范围。

您需要将此与Sublime用户首选项中的drawWhiteSpace:“all”,相结合使用。


无论空格或制表符: "pattern": " +|\t+" - lawlist
4
当前设置为:draw_white_space - d_rail
1
draw_white_space has three values: none, selection (default), and all - Don Wilson

3
你可以通过改变前景透明度来改变选项卡下划线的透明度。
要更改空格的颜色,需要对每个语法文件进行更改

前景透明度似乎会影响选项卡和行号(但不影响空格)。 - oluc

2
几年后,我在 Sublime Text 3 build 3083 中遇到了这个问题。希望这能帮助任何人。除了 Chris Like 建议安装 PersistentRegexHighlight 并在用户首选项中设置 "draw_white_space": "all" 和模式为一个或多个制表符和空格的出现,即 [ \t]+ 在 PersistentRegexHighlight 用户设置中,我还必须设置 "color_scope": "highlight.whitespace" 并将以下字典添加到主题中,以及其他设置数组中的其他项:
<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>

顺便提一下,只有在背景设置为黑色(即 #000000)时,它才用红色进行轮廓线勾画,这很奇怪。
请注意,此方法不需要编辑任何语法文件。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接