tags:

views:

237

answers:

2

I want to modify the solution for highlighting trailing whitespace described here by NOT highlighting whitespace on otherwise empty lines.

I've modified this in my Python language file:

     { match = '(\s+)$';
  captures = { 1 = { name = 'invalid.whitespace'; }; };
 },

To this:

     { match = '\S(\s+)$';
  captures = { 1 = { name = 'invalid.whitespace'; }; };
 },

This new expression doesn't seem to match anything anymore. What am I doing wrong ?

+1  A: 

Try assertions:

(?<=\S)\s+$

They're described nicely in PHP manual (they're not PHP-specific of course, just php.net happens to have quite readable version of the document).

porneL
Ahh very close. It's actually (?<=\S)\s+$Update your answer and i'll mark it as the solution. (i guess that's how this is supposed to work)
rhettg
+1  A: 

The problem with your pattern is that the preceding non-space character is presumably already matched by another rule, and thus is not available to your rule. Using an assertion as porneL suggests is the correct wayt to do this.

Kevin Ballard