Home Download Buy Blog Forum Support

Problem with script that highlights trailing spaces

Problem with script that highlights trailing spaces

Postby rchl on Sat Mar 12, 2011 1:01 pm

At http://sublimetext.userecho.com/feedback/21171-search/ I found a tip how to highlight trailing spaces.

Problem is that I can't figure out how to customize color (posted question there but not sure if commenter was notified and if I will ever get reply there).

Script source is here: https://bitbucket.org/theblacklion/subl ... _spaces.py

It does:
Code: Select all
view.add_regions('HighlightTrailingSpacesListener', regions, color_name,
                         sublime.DRAW_EMPTY_AS_OVERWRITE)

so I've added custom scope to theme I'm using (Twilight) like this:

Code: Select all
      <dict>
         <key>name</key>
         <string>Trailing whitespace</string>
         <key>scope</key>
         <string>trailingspace</string>
         <key>settings</key>
         <dict>
            <key>background</key>
            <string>#FF0E09</string>
            <key>foreground</key>
            <string>#F8F8F8</string>
         </dict>
      </dict>

and set DEFAULT_COLOR_NAME = 'trailingspace' in script. Unfortunately, trailing spaces have white background with this change. When using default "comment" scope, they have no background color (or same as buffer background) so changing color seems to make some difference but not the one I expect.
rchl
 
Posts: 147
Joined: Fri Mar 04, 2011 11:02 pm

Re: Problem with script that highlights trailing spaces

Postby theblacklion on Sun Mar 13, 2011 1:42 pm

Sublime uses the foreground color to fill those regions. So set your foreground color to your reddish one. You also might have to close and reopen your file to see the changes.

P.S. Sorry - but it has been only 3 days since your post on userecho and I had the notification waiting in my inbox ;).
theblacklion
 
Posts: 67
Joined: Sat Feb 05, 2011 10:07 pm
Location: Hannover, Germany

Re: Problem with script that highlights trailing spaces

Postby rchl on Sun Mar 13, 2011 2:39 pm

That works! Thanks.

I also found another "problem". When highlight timeout is set to 500 for example, and I'm typing a sentence fast, I would expect to not see trailing spaces being highlighted during typing when I don't make such long breaks during typing. They are still highlighted briefly and I believe it's because previous sublime.set_timeout's are triggering. Having sublime.clear_timeout would probably help here but it seems like it's not implemented.

BTW. Sorry for being impatient, I wasn't sure if there is notification system in place there. :)
rchl
 
Posts: 147
Joined: Fri Mar 04, 2011 11:02 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 23 guests