2

I'm using the ntpeters/vim-better-whitespace plugin to automatically highlight trailing whitespaces (and removing them). I also want to highlight "irregular" whitespace characters, such as  (U+00A0) and so I've added this to my .vimrc;

highlight IrregularWhitespace ctermbg=red
match IrregularWhitespace / / " U+00A0 (not a traditional space)
autocmd BufWinEnter,CursorMovedI * highlight IrregularWhitespacee ctermbg=red

However, if I have the vim-better-whitespace plugin enabled, this does not seem to work at all? If I disable the plugin, it works exactly like I want it to.

  • 2
    You'd better ask to the developer here – statox Jun 1 '16 at 15:24
3

If you're just looking to see that character I believe this will do the trick:

set list listchars=nbsp:·

You can put whatever character you like after the colon.

See :h listchars for more info.

If you wanted to change the hilighting of that character you can use

highlight SpecialKey...

But be warned that this will also affect the representation of characters like ^Z as well.

  • That feels like quite a hack though? Am I misunderstanding how autocmd/highlight works or is the plugin actually breaking something? – Unidan Jun 1 '16 at 16:12
  • listchars is fully supported by vim. How is this a hack? I haven't looked at the plugin, as I don't feel like wading through code, but if you feel so inclined, you might check if it also defines the same autocmd. I was merely trying to provide you with a simpler way that might not interfere with the plugin. – Tumbler41 Jun 1 '16 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.