I’m using an Apple Magic Keyboard on a Linux machine at work. Now it happens from time to time that I receive strange errors while programming. In IntelliJ even on some completions. Then a space is shown with a red wavy 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
While writing another article with xed on Linux Mint, it happened again.
bless ~/Documents/myfile.md I wanted to know how this get 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
But why? Why and how does this non-breaking space happen?
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 also made when pressing Shift+Space. I knew it only from Option+Space on the Mac.
This is very annoying for those of us, who already press 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 my 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”.