How to safely break in iex

Sat, May 14, 2022 0 min read
Break from current statement in iex, with unmatched quotes or parentheses, without exiting shell

Sometimes, when you forget to close a quote, double quote, or brackets, it will continue to create new lines when you press enter.

You can exit by pressing Ctrl+c twice, but you will leave the interactive shell.

If you want to stop the statement, you are inserting, just add #iex:break. It will error out, but you will still be in the shell.

iex(1)> IO.puts("dssdsda
...(1)> asdasdsda
...(1)> sadsadsda
...(1)> #iex:break
** (TokenMissingError) iex:1: incomplete expression