MacOS – Disable non-breaking space (Option-Space) specifically in Xcode

keyboardmacosxcode

There's a pretty general solution for disabling the non-breaking space in OS X for some apps:

https://superuser.com/questions/78245/how-to-disable-the-option-space-key-combination-for-non-breaking-spaces

Unfortunately, Xcode is not one of them, and the solution does not work.

Any ideas on how to disable Option-Space for Xcode specifically?

I'm using a slightly customized keyboard layout, created with Ukulele; perhaps it could be used to remap that particular combination?

I'd rather not use stuff like KeyRemap4Macbook (or whatever it's called), since I've experienced a considerable, unacceptable lag during typing when using that app with some remaps.

Best Answer

I have found a somehow dirty workaround to disable the key combination for Xcode only:

To disable alt/optspace add a new keybinding in the file IDETextKeyBindingSet.plist in the folder /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources.

Open the plist and add a new dictionary called 'Customized'. Create a new child named 'Insert No Alt-Space' with type 'String' and the value 'InsertSpace:'. Save the file.

Open Xcode -> Preferences -> Key Bindings -> Customized
Highlight 'Insert No Alt-Space' -> Key and enter alt/optspace.

In the future you will get an audible error message typing the combination but nothing will be written.

Until now i haven't found a method to just insert a space instead of a non-breaking space.

Probably you have to redo the modification with every new Xcode version.