# Example for Base.edit and Base.less

**URL:** <https://discourse.julialang.org/t/example-for-base-edit-and-base-less/8797>\
**Category:** General Usage\
**Created:** [February 4, 2018, 12:33am UTC](https://discourse.julialang.org/t/example-for-base-edit-and-base-less/8797 "2018-02-04T00:33:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivo\_welch](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@ivo\_welch](https://discourse.julialang.org/u/ivo_welch)\
**Post date:** [February 4, 2018, 12:33am UTC](https://discourse.julialang.org/t/example-for-base-edit-and-base-less/8797/1 "2018-02-04T00:33:30Z")

</div>

Could someone please post an example of how to use Base.edit?

```julia
julia> f() = rand()*2
f (generic function with 1 method)

julia> f(x) = rand()+x
f (generic function with 2 methods)

julia> edit(f)

```

also, how do I see the definition of a struct ?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 4, 2018, 7:19am UTC](https://discourse.julialang.org/t/example-for-base-edit-and-base-less/8797/2 "2018-02-04T07:19:17Z")

</div>

I usually go with the macro form, eg

```julia
@edit f(1)

```

would take me to the definition **in the source file**. It won’t be able to do that with a function you typed in from the REPL. I find it is best with a workflow based on [Revise.jl](https://github.com/timholy/Revise.jl). Also, you need to set up your editor correctly, eg

```julia
ENV["EDITOR"] = "emacsclient"

```

in your `~/.juliarc.jl`.

AFAICT `struct`s are not supported ATM (by the underlying `Base.functionloc`). See [#14356](https://github.com/JuliaLang/julia/issues/14356). But you can work around this in many cases by using the constructor, eg

```julia
@edit Date(1980, 1, 1)

```

and hope the `struct` definition will be somewhere in the vicinity 😄

---

<div class="post-metadata">

**Author:** ![ivo\_welch](https://avatars.discourse-cdn.com/v4/letter/i/d2c977/32.png) [@ivo\_welch](https://discourse.julialang.org/u/ivo_welch)\
**Post date:** [February 4, 2018, 7:18pm UTC](https://discourse.julialang.org/t/example-for-base-edit-and-base-less/8797/3 "2018-02-04T19:18:33Z")

</div>

thanks, but yikes. seeing or editing would be useful exactly when I had entered a function in the REPL. when it is in a source file, I can just use my external editor on the source.

because neither @less nor @edit works for REPL entered code, is there no way to display my function source? and/or my struct source?
