Elixir wraps output on 80th character

Like any modern computer, mine can show more than 80 characters on screen, but if i run mix task or run code through iex output is shown only in 80 columns.

%{1 => %{1 => nil, 2 => nil, 3 => nil, 4 => nil, 5 => nil, 6 => nil, 7 => nil,
    8 => nil},
  2 => %{1 => nil, 2 => nil, 3 => nil, 4 => nil, 5 => nil, 6 => nil, 7 => nil,
    8 => nil},
  3 => %{1 => nil, 2 => nil, 3 => nil, 4 => nil, 5 => nil, 6 => nil, 7 => nil,
    8 => nil},
  # ... etc

I use iTerm2 with zsh as shell and Elixir and I don’t have this problem with python nor ruby. Any suggestion what is the cause? It’s a minor annoyance, but still i’d like to fix it.

1 Like

I believe it’s an iex configuration option.

Width

An integer indicating the number of columns to use in documentation output. Default is 80 columns or result of :io.columns, whichever is smaller. The configured value will be used unless it is too large, which in that case :io.columns is used. This way you can configure IEx to be your largest screen size and it should always take up the full width of your terminal screen

It works great for iex but not for mix :confused: But I know where to search more now :slight_smile:

IO.inspect(smth, width: 160) works too :slight_smile:
IO.inspect(smth, width: :infinity) outputs everything in one long line :slight_smile:

PS. IEX revelang docs http://elixir-lang.org/docs/stable/iex/IEx.html#module-configuring-the-shell

iex> :io.columns
{:error, :enotsup}

Huh…

It definitely does not take up my full screen size though, less than half of the available width. It really should default to the width and resize properly as the screen is resized as well…

iex(1)> :io.columns
{:ok, 157}

Reports exactly how much there is. I have 158 columns width terminal :slight_smile:

Should not this be calculated by default? I think it is not good to setup system konsole and elixir konsole to use all available space.

Windows… My guess is that is why the default is set at 80 and there’s no attempt to calculate it.

For good or ill, elixir tooling tends to err on the side of making windows and unix as similar as possible. When it comes to adding features that would work on unix and not at all on windows, that feature is not implemented in my experience.

2 Likes