macOS Terminal Unexpected token when using IEx or Vim

Hi!

I have an annoying issue on macOS when using Elixir and vim or IEx on macOS. When I write a pipe (|>), I often accidentally hold the option key before hitting space and pipe. But it seems that this combination, option + space writes an alternative kind of space.

In this example, the first command succeeds, but the second fails because it has the “alternative space” in it:

iex(1)> [1,2,3,4] |> Enum.map(& &1 * 2)
[2, 4, 6, 8]
iex(2)> [1,2,3,4] |> Enum.map(& &1 * 2)
** (SyntaxError) iex:2:13: unexpected token: " " (column 13, code point U+00A0)

I’m using Terminal.app on macOS 11.

Does anyone know a workaround for this. Perhaps a way to disable option+space or remap it to regular space?

Updated: I found some workarounds here. It seems that the error is that macOS inserts a “non-breaking space” when hitting option-space.

I wish there was a good option for just remapping it in Terminal.app. It has never been an issue before switching to Elixir, I guess I didn’t use pipes as much before :slight_smile: