Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight non-breaking space in VIM, different behavior between command and .vimrc

Tags:

vim

I want non-breaking space to be immediatly highlighted when I type one in VIM, because my keyboard's layout makes me sometimes write non-breaking space instead of normal space, and then it's a hard time debugging.

I found a cool trick, entering the command :

:syntax match ErrorMsg " "

does exactly what I want (the space between quotes is a non-breaking space)

Now when I add this command to .vimrc (without the beginning colon) it doesn't work… any idea?

like image 806
Quentin Avatar asked May 04 '26 01:05

Quentin


1 Answers

May depend on how you are entering it into .vimrc, but try:

au VimEnter,BufWinEnter * syn match ErrorMsg " "

Personally I think it would make more sense to map the typing of that space to the Space -- how often do you need to type a non-breaking space? Or maybe you can fix the issue at its source: the keyboard layout.

like image 157
Explosion Pills Avatar answered May 06 '26 08:05

Explosion Pills



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!