Override default object display length in REPL/env?

No, apparently there is no easy solution. 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> 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:
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> 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

2 Likes