# Override default object display length in REPL/env?

**URL:** https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246
**Category:** General Usage
**Tags:** repl, display
**Created:** [October 5, 2021, 5:37pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246 "2021-10-05T17:37:38Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![marerik](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@marerik](https://discourse.julialang.org/u/marerik)
#### Post date: [October 5, 2021, 5:37pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246/1 "2021-10-05T17:37:38Z")

</div>

If I want to display a large object (vector, array, matrix, etc) in the REPL, it will typically echo/display it, but incompletely with ellipses denoting the undisplayed/suppressed values.

Is there a way to override the length of the displayed object as a standard environment variable? It seems like this should be easy to do but I have not figured out a way to do it.

show() and @show will display an object but it’s just dumped without any formatting, which makes it difficult to read, and in any event, I have to do it on a case-by-case basis, rather than it being an environment/REPL setting.

I’ve tried using ENV[“LINES”] and setenv() but that doesn’t seem to work. Config() doesn’t seem to include anything related to this issue.

Any advice? It seems like this should be lurking somewhere in the REPL internals.

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [October 5, 2021, 6:30pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246/2 "2021-10-05T18:30:02Z")

</div>

No, apparently [there is no easy solution](https://discourse.julialang.org/t/more-less-head-tail-to-display-arrays-in-repl/47435). The workarounds are:

1. Use ` ;` to avoid printing at all if you don’t want to see the data.

2. If you actually know what you want to see, use slices:

```julia
julia> x = rand(300,300);

julia> x[1:3,1:3]
3×3 Matrix{Float64}:
 0.201148 0.343138 0.680792
 0.912477 0.670834 0.0462071
 0.497209 0.519856 0.501574

julia> x[1:2,:]
2×300 Matrix{Float64}:
 0.201148 0.343138 0.680792 0.250896 0.762277 … 0.947869 0.663313 0.331605 0.55514 0.69662
 0.912477 0.670834 0.0462071 0.866555 0.430131 0.705827 0.500807 0.28222 0.117387 0.232216

julia> x[end-2:end,:]
3×300 Matrix{Float64}:
 0.530914 0.288524 0.25518 0.719391 0.617756 … 0.754256 0.663696 0.624188 0.0637987 0.966756
 0.906517 0.724708 0.6759 0.756997 0.0216099 0.534473 0.709289 0.986315 0.733846 0.476186
 0.314051 0.712171 0.0621085 0.516785 0.563678 0.766445 0.79259 0.907545 0.46412 0.921298

```

1. Edit the data: I sometimes use this function:

```julia
function edit!(x)
    tmp_file_name = tempname()
    writedlm(tmp_file_name,x)
    InteractiveUtils.edit(tmp_file_name)
    x .= readdlm(tmp_file_name)
end

```

With that, you can actually view the data and even edit it on your default text editor, with:

```julia
julia> x = rand(2,2)
2×2 Matrix{Float64}:
 0.987879 0.215942
 0.974738 0.975242

julia> edit!(x) # open vim and changed the first value to zero
2×2 Matrix{Float64}:
 0.0 0.215942
 0.974738 0.975242

```

---

<div class="post-metadata">

### Author: ![marerik](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@marerik](https://discourse.julialang.org/u/marerik)
#### Post date: [October 7, 2021, 2:23pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246/3 "2021-10-07T14:23:58Z")

</div>

Thanks. Your impression regarding lack of solutions is the same as mine. It’s surprising to me, as I’d think the default if anything would be to display the whole object, and that there would be an easy way to change the setting otherwise.

Slices sometimes works but sometimes you don’t really know.

I like your idea of the edit function. I’ve been trying it on my system; I can get it to open in an editor but then for some reason it usually crashes.

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [October 7, 2021, 2:27pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246/4 "2021-10-07T14:27:09Z")

</div>

> [@marerik](#):
>
> I can get it to open in an editor but then for some reason it usually crashes.

That specific function does not allow you to remove elements or other editions (because of the broadcasted reassignment of the values with `.=`). This is a little bit more general and perhaps useful, but has to be called with reassignment on return:

```julia
julia> using DelimitedFiles

julia> function edit!(x)
           tmp_file_name = tempname()
           writedlm(tmp_file_name,x)
           InteractiveUtils.edit(tmp_file_name)
           return readdlm(tmp_file_name)
       end
edit! (generic function with 1 method)

julia> x = rand(2,2)
2×2 Matrix{Float64}:
 0.913052 0.578263
 0.254731 0.435317

julia> x = edit!(x) # note the reassignment (removed first line)
1×2 Matrix{Float64}:
 0.254731 0.435317

```

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [October 7, 2021, 3:03pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246/5 "2021-10-07T15:03:16Z")

</div>

The [TerminalPager.jl](https://github.com/ronisbr/TerminalPager.jl) package [announced here](https://discourse.julialang.org/t/ann-terminalpager-jl-v0-2-0/61616) is awesome for that purpose.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [October 7, 2021, 4:12pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246/6 "2021-10-07T16:12:51Z")

</div>

> [@marerik](#):
>
> Is there a way to override the length of the displayed object as a standard environment variable?

See [Provide a simple way to print all entries in a collection · Issue #29223 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/29223) … in particular, you can do:

```julia
show(stdout, "text/plain", x)

```

---

<div class="post-metadata">

### Author: ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)
#### Post date: [October 7, 2021, 4:22pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246/7 "2021-10-07T16:22:45Z")

</div>

You can do this, possibly in `.julia/config/startup.jl`:

```julia
julia> Base.active_repl.options.iocontext[:displaysize] = (200, 2000)
(200, 2000)

julia> (1:100)'
1×100 adjoint(::UnitRange{Int64}) with eltype Int64:
 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

```

---

<div class="post-metadata">

### Author: ![marerik](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@marerik](https://discourse.julialang.org/u/marerik)
#### Post date: [October 10, 2021, 3:54pm UTC](https://discourse.julialang.org/t/override-default-object-display-length-in-repl-env/69246/8 "2021-10-10T15:54:28Z")

</div>

Thanks — these are all great suggestions and very helpful. I agree with some of the comments in that issue thread that this could be made easier to address in the Julia docs. A dedicated topic in the REPL section might help.
