IEx - How to cancel a multiline command?

When I use IEx and make a typo as an extra parenthesis or ", most of the time I get a syntax error. But there are cases like this:

iex(3)> Enum.each '12345', &(IO.puts(&1")) ...(3)> end ...(3)> ) ...(3)> ' ...(3)> end ...(3)> "" ...(3)> ... ? How to produce syntax error ? ...(3)> BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution 

I cannot make a syntax error and continue from scratch, and I need to restart the entire IEx. Is there a keyboard shortcut or command to skip the execution of the current iex (3) and move on to the next iex (4)?

+47
elixir
Dec 21 '14 at 16:36
source share
2 answers

Start your line with #iex:break

 iex(1)> Enum.each '12345', &(IO.puts(&1")) ...(1)> ... ...(1)> #iex:break ** (TokenMissingError) iex:1: incomplete expression 
+47
Dec 21 '14 at 17:47
source share

In general, you can also press Ctrl-G, which will take you to the "User switch command" mode with the prompt ---> . From here, you can enter i to end the IEx session, then c to reconnect to it; IEx will then indicate ** (EXIT) interrupted and return to the state it was in before you got stuck. This is a feature of the Erlang (erl) shell that was inherited by IEx.

An example of this in action:

 iex(3)> Enum.each '12345', &(IO.puts(&1")) ...(3)> end ...(3)> ) ...(3)> ' ...(3)> end ...(3)> "" ...(3)> <-- Ctrl-G goes here (not shown normally) User switch command --> i --> c ** (EXIT) interrupted iex(3)> 
+36
Jan 23 '15 at 19:25
source share



All Articles