ANN: InteractiveCodeSearch.jl --- Interactively search Julia code


Let me introduce my package InteractiveCodeSearch.jl. It helps you searching Julia code.

gif animation

Julia has @edit, @less, etc. which are very handy for reading the implementation of functions. However, you need to specify a “good enough” set of (type) parameters for them to find the location of the code.

Instead, InteractiveCodeSearch provides a few macros to interactively choose the code you want to read. Features:

  • Interactively choose a method signature before opening the code location in your editor.
  • Various ways to search methods, such as: by function name @search show, function call expression @search show(stdout, "hello"), function call signature @search show(::IO, ::String), module name @search Base, argument value @searchmethods 1, argument type @searchmethods ::Int, and return type @searchreturn Int.
  • Interactively search history. It works in IJulia as well.

It’s already registered so you can install it by:

]add InteractiveCodeSearch         # Julia ≥ 0.7
Pkg.add("InteractiveCodeSearch")   # Julia 0.6

EDIT: I forgot to mention that the most of the cool things are happening in the interactive matching program. I use peco (written in Go) and InteractiveCodeSearch is useful (e.g., it can handle @search Base) because peco is highly efficient.

My mental load using Julia is much higher than, e.g., in Python. How to reduce it?

Wow, this works really well!


I’m glad that you find it useful!


I wasted some time thinking I need peco.jl to get this working, but now it works.

You think it would be possible to have a special key in the REPL that would trigger @search? For example ‘)’ .


Ah, I guess README is not very clear about installation steps.

Yeah, that’s possible. I’ve done it in IPython.jl. Maybe it would be nice to have something context-aware like alt-e in Rebugger.jl.


Putting this in ~/.julia/config/startup.jl seems to work:

using REPL
using REPL: LineEdit

@async begin
    # This is why we need
    for _ in 1:20

    repl = Base.active_repl
    repl isa REPL.LineEditREPL || return
    insert_search = function(s, _...)
        if isempty(s) || position(LineEdit.buffer(s)) == 0
            LineEdit.edit_insert(s, "@search ")
            LineEdit.edit_insert(s, ')')
    new_keymap = Dict{Any,Any}(')' => insert_search)

    main_mode = repl.interface.modes[1]
    main_mode.keymap_dict = LineEdit.keymap_merge(main_mode.keymap_dict,



Thanks for this great tool! It will be nice to have it integrated to REPL out of the box.

I’m using Visual Studio Code as my default editor but I get:

julia> @search show
[ Info: Opening options.jl:54
Unknown editor: no line number information passed.
The method is defined at line 54.

Is there a way to go directly to line number?

If Visual Studio Code can’t be supported for now maybe @davidanthoff can help or give some tips / advices to improve its support.

Maybe doc should provide information to set InteractiveCodeSearch.jl with an other editor (with go to line number supported).

Thanks again @tkf that’s a great contribution

Kind regards


You might need to set the JULIA_EDITOR environment variable (e.g. add JULIA_EDITOR=code to your ~/.bashrc on Linux).


As @tkoolen mentioned, setting environment variable JULIA_EDITOR, VISUAL or EDITOR should work. This should also make stdlib @edit work.

Behind the scene, as briefly noted in the README, default configuration for opening an editor is = edit where edit is from the standard library InteractiveUtils (see:{AbstractString,Integer}). If, for some reasons, you want to bypass stdlib edit, you can define your own function of the form function(file, line::Integer) and set it to