I’m using an Apple Magic Keyboard on a Linux machine at work. From time to time it happens that I receive strange errors while while working. This occurs in IntelliJ even on some completions. Then a space is shown with a red waved underline.

On compile, this warning can occur:

Error:(38, 31) java: illegal character: '\u00a0'

or even bash commands become unknown:

$ echo "test"
zsh: command not found: echo test

With bless ~/Documents/myfile.md I wanted to know how this gets so messed up. After selecting the space in bless, a hex representation of C2 A0 was displayed. After some internet research, it became clear that this is a non-blocking space, depending on the encoding of the file it gets represented as 00 A0 or C2 A0.

But why? Why and how was this non-breaking space introduced?

I started a terminal and executed sudo showkey -a to monitor all keys pressed. So I pressed various combinations with the spacebar until I got this output:

  	194 0302 0xc2
 	160 0240 0xa0

while pressing Shift+Space. Got ya! So on my Swiss-German-Apple-Keyboard-Layout the non-breaking space is created pressing Shift+Space. I did know that character only from Option+Space on the Mac.

This is very annoying for those of us, pressing shift, when we are about to write a capital letter after the next space.

The interface to change that setting is not included in the standard gnome preferences. In order to change the setting you have to install gnome-tweaks

sudo apt install gnome-tweaks

Start Gnome Tweaks and in “Keyboard & Mouse” -> “Additional Layout Options” you’ll find the setting “Using space key to input non-breaking space”. For me “Usual space at any level” works fine, since I’ve never used a non-breaking space before. And the problem is gone!

Linux Mint: For Linux Mint there is already a GUI to change that, you don’t need gnome-tweaks. Go to Settings -> Keyboard -> Select “Layouts” tab -> “Options…” at the right bottom corner. There is a list and one says “Using space key to input non-breaking space”.