Multi-line history at the IEx prompt

I was looking into the state of multi-line history in IEx. To be clear, all I want is the ability to hit the up arrow and get back all of the lines of a multi-line expression. Ctrl-R working would be nice too. I found several posts, git commits and issues related to this. Let me share what I found:

  1. Erlang has supported multi-line history since the OTP 26 shell updates. This works perfectly for me in Erlang, but doesn’t transfer over to Elixir like other shell improvements.
  2. José’s branch at GitHub - elixir-lang/elixir at jv-get-until-parser-26 works really well. It’s referenced in the “to be implemented when we exclusively support Erlang 27” section at Support Erlang/OTP 27 new features · Issue #12857 · elixir-lang/elixir · GitHub, though.
  3. The GitHub - nhpip/iex_history2: An improved history for the Elixir IEx shell project supports it today.

Given Elixir’s Erlang support policy, I’d expect Erlang 27 to be exclusively supported in 2026.

The iex_history2 project is pretty interesting, but has just enough friction to enable that I don’t expect myself to use it most of the time. This is not a criticism of the project, but just that it would be easier for me if IEx did this out of the box.

Since I mostly use Erlang 27 these days, I’m tempted to run a custom version of Elixir with the patch.

Is there another option that I missed?

10 Likes

I would love proper support for multiline in iex, I can’t tell you how many times I get annoyed by these limitations when I have to debug stuff on deployed servers.

1 Like

Yeah…iex_history2 was my first-elixir project. I wrote it for 2 reasons.

  1. Multi-line paste
  2. The ability to save variable bindings.

I need to update it.

4 Likes

The current workaround I’ve been experimenting with is to tinker with wip multi-line expressions in a scratch/temp file or directly in a working file below a pry/breakpoint within a debugging session and then use a shortcut to pipe those multiline expressions into the iex session.

Granted, it’s a pretty specific workflow as it relies on vim, tmux, and the plugin vim slime to bridge the editor with the repl and gets me a bit closer towards repl/test driven development nirvana when paired with IEx’s ability to reload/recompile changes within a pry session.

All that said, I’m also looking forward to better multi-line history support with IEx itself!

3 Likes