Search code examples
sublimetext3textmate

Apply background color to text region only


In my theme, I've set the background color for comments. But the color is applied to the entire row, rather than just the area with text. Is there a theme setting I can use to fix that?

enter image description here


Solution

  • The Sublime Text theme engine relies on the scopes defined in the language syntax. Executing view.scope_name(view.sel()[0].begin()) in the Sublime Console when the cursor is inside the comment shows source.python string.quoted.double.block.python - and is the same when the cursor is in a whitespace section of the string and when it isn't. This means you would need to alter the python language definition that Sublime uses to report a different scope when relevant, for example, string.quoted.double.block.whitespace.python, before you can use it in your theme.