Colton Myers
Colton Myers

Reputation: 1341

Highlighting tab characters in Sublime Text (2 or 3)

Is there a way I can highlight just tab characters? I know about "draw_white_space": "all" but I don't want to highlight all whitespace, just tabs.

There doesn't seem to be a plugin or a setting that fits the bill. I'd like to avoid writing a new plugin, but I will if I have to.

Thanks in advance!

Upvotes: 1

Views: 1584

Answers (2)

lawlist
lawlist

Reputation: 13457

I have only tested this on SublimeText2. As an alternative to PersistentRegexHighlight, you could use the following minor modifications to the theme and language files. Please feel free to disregard / remove the whitespace definitions -- I included them because someone else may be interested in seeing how to modify Theme / Language files:

Excerpt from whatever language syntax you want -- e.g., LaTeX.tmLanguage

<!-- BEGIN whitespace / tab definitions -->
<dict>
  <key>match</key>
  <string>\t+</string>
  <key>name</key>
  <string>lawlist.tab</string>
</dict>

<dict>
  <key>match</key>
  <string> +</string>
  <key>name</key>
  <string>lawlist.space</string>
</dict>
<!-- END -->

Excerpt from whatever theme you are using -- e.g., lawlist.tmTheme

<!-- BEGIN whitespace / tab definitions -->
<dict>
  <key>scope</key>
  <string>lawlist.tab</string>
  <key>settings</key>
  <dict>
    <key>fontStyle</key>
    <string></string>
    <key>foreground</key>
    <string>#FF0000</string>
    <key>background</key>
    <string>#FFFFFF</string>
  </dict>
</dict>
<dict>
  <key>scope</key>
  <string>lawlist.space</string>
  <key>settings</key>
  <dict>
    <key>fontStyle</key>
    <string></string>
    <key>foreground</key>
    <string>#000000</string>
    <key>background</key>
    <string>#FFFFFF</string>
  </dict>
</dict>
<!-- END whitespace / tab definitions -->

Upvotes: 1

skuroda
skuroda

Reputation: 19744

I haven't worked on this plugin in a while, but you can try PersistentRegexHighlight. You will just need to define a regex pattern for the tabs and a color to highlight with if you don't like the default.

Upvotes: 3

Related Questions