Highlight nbsp \xA0 in vim

1

I have some patterns in my vimrc to match weird characters in files such as tabs, curly quotes, em-dashes, etc.

" Highlight various difficult-to-see problems
:match Error / \t/
:match Error /–/
...

How can I add ASCII non-breaking space \xA0 to this list?

I encountered one of these nbsps in a file when I was doing some diffs, I'm not sure how it got in there, but I had to use a hex editor to see what was going on.

Similarly, in the image, you can see that this turns up as what is, and isn't a space.

nbsp affecting highlights

mgjk

Posted 2017-09-03T11:35:52.210

Reputation: 1 337

Answers

3

See :help character-classes:

:match Error /\%xA0/

romainl

Posted 2017-09-03T11:35:52.210

Reputation: 19 227

Thanks for the tip on the help command too. Sometimes I forget it's there, but it's certainly well worth reading. – mgjk – 2017-09-04T09:32:49.903

1I would say it's the most important thing to learn. – romainl – 2017-09-04T11:07:13.250