I wanted julia to automatically figure out and set the editor for use with
@edit depending on if I was in a terminal (use vim) or if I was in vscode julia repl (use vscode).
I saw that in julia vscode settings there is a part about
Command to open files from the REPL (via setting the
JULIA_EDITORenvironment variable). Defaults to
so I added the line
"julia.editor": "code" to my
settings.json while having
ENV["JULIA_EDITOR"]="vim" in my
startup.jl and expected this to mean that in a standalone terminal I would get vim while in vscode julia repl it would overwrite this and set it to code. But it seems like both are just opening in vim still, and checking
ENV["JULIA_EDITOR"] in the vscode repl it shows vim, so I guess I misunderstood how this works?
I came up with some simple workaround using my
startup.jl which just checks if there are any vscode related env vars and if so we set editor to vscode, otherwise it is vim.
if isempty(filter(contains("VSCODE"), keys(ENV))) ENV["JULIA_EDITOR"] = "vim" else ENV["JULIA_EDITOR"] = "code" end
This seems to work fine locally, but I also work on remote instances quite a bit where my
startup.jl isn’t always present.
On remote instances it seems like it is not working at all even if it seems to set the editor to some default value that seems reasonable, but ignoring my setting
"julia.editor": "code" (which might have been wrong here, but still it is ignored?).
julia> @edit 1+1 julia> /opt/julia-1.6.5/share/julia/base/int.jl:1 # This file is a part of Julia. License is MIT: https://julialang.org/license ^ SyntaxError: Invalid or unexpected token at wrapSafe (internal/modules/cjs/loader.js:979:16) at Module._compile (internal/modules/cjs/loader.js:1027:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 julia> ENV["JULIA_EDITOR"] "\"/home/ubuntu/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/node\""
I assume that has to do with it not being a “real” installation or something, just some remote node, but if it was possible to make this work it would be convenient.
Have I gotten the wrong setting, is it called something else than
julia.editor? How am I supposed to figure out the exact name in general, the text doesn’t mention what the name is?