1

Is there a way to highlight zero-length characters in text files (PHP/HTML in this case). I recently had an issue with a web page not passing W3C validation due to a invalid character.

As the character in question was a ZERO WIDTH NO-BREAK SPACE, it took an age to actually find it. It was purely by accident that I used git diff and it showed up as being <U+FEFF>.

It would be great if I was able to see these types of characters actually in SublimeText while I'm working on a source file.

I've turned on showing up whitespace by adding:

"draw_white_space": "all"

to my user preferences, but while that does show spaces and tabs, it doesn't show this character up.

Steve Holland
  • 619
  • 1
  • 12
  • 29

1 Answers1

1

See this answer. The answer is Sublime Text specific, but the question is not.

The linked answer suggests using the Highlighter package which, according to the docs is

A plugin for Sublime Text 2 and 3 that highlights mixed tabs and spaces and some unicode characters.

You can add \uFEFF to the list of regexes to highlight.

Community
  • 1
  • 1
AGS
  • 14,288
  • 5
  • 52
  • 67
  • Thanks for the suggestion. I've added the package with the config as detailed in the answer. It already had the `\uFEFF` tacked onto the end of the regex. Sadly it doesn't seem to want to highlight that particular character, the rest of them seem to get highlighted though. – Steve Holland Mar 31 '15 at 10:08