Shortcut to display an entire vector in the REPL

Is there a way to have the REPL not elide the middle elements from
the display of an array or vector?

This has probably been asked before but I can’t find the reference or a
solution. This is probably one of the pain points with julia for me as it
comes up all—the—time and it seems like there should be a resolution
for the issue by now.

The FAQ makes no mention. How have others solved the problem?

v = collect(1:1000)
show(v)
display(v)
println(v)

Or are you looking for a more permanent solution?

Is there a reason you need display to handle this instead of looping through elements and printing what you need?

Yes.

For a one-time thing, do show(stdout, "text/plain", array) to mimic the REPL output (which happens via display) but not limit output. Or just do show(array) or println(array) to get compact (single-line) non-truncated output.

To change the REPL display globally, you can change its IOContext (see the docs here):

Base.active_repl.options.iocontext[:limit] = false

See also the summary in the manual about how the different output functions interact: Output-function summary.

4 Likes

I’m looking for less work in the solution that preserves the standard REPL interface.

I want the REPL to “do what I want” here without extra effort.

This appears to do what I want. Keep the same REPL interactions but not
skipping the middle elements of large displays. It would be nice if the REPL
would allow you to toggle this as a feature.

Marking this as the solution and thanks for all the reference information.

This works nicely with TerminalPager.jl

It already does, no?

That being said, I would really like to see a better API here: julia#61005.

I’ve tried and failed before to come up with a shorthand for doing this in the repl. I think it would be good to figure that out.

1 Like
macro p(ex)
    :(println($(esc(ex))))
end
DataArray1 = collect(1:100)

@p DataArray1
# 
julia> @p DataArray1
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]```