I have this annoying problem since long. I use to type quite fast, and it happens to me that after inserting a special character using the "alt" key I probably do not wait enough to press the space bar. I don't see the difference then, but then when the command is interpreted in the terminal, or the script I just wrote is executed, lots of errors come up because there are hidden strange characters (gremlins). Is there any way I can avoid this?
Your option + space combination defaults to a non-breaking space and several options to remove that binding exist.
Whether you choose to show invisible characters in your editor to manually proof for these issues or use a lint type tool or change the behavior of the system depends on whether you can avoid typing that combination after knowing it exists.