"/home/grimm"
julia>
julia> using Pkg
julia> Pkg.generate("HelloWorld")
Generating project HelloWorld:
HelloWorld/Project.toml
HelloWorld/src/HelloWorld.jl
Dict{String, Base.UUID} with 1 entry:
"HelloWorld" => UUID("0f36ea27-3fa5-45e8-8aed-a1573f2015cd")
(HelloWorld) pkg> activate ~/HelloWorld
Activating project at `~/HelloWorld`
(HelloWorld) pkg> instantiate
No Changes to `~/HelloWorld/Project.toml`
No Changes to `~/HelloWorld/Manifest.toml`
Precompiling project...
1 dependency successfully precompiled in 1 seconds
Iβm learning to navigate within the Julia REPL (using Linux Mint) - for ex - creating a simple pkg above works fine. I know to use pwd() to be sure Iβm in the right directory and cd(βpath to filesβ) - but if I want to say, change the text inside the HelloWorld.jl file(located in the src directory) I have to exit REPL, back to Linux file system, open HelloWorld.jl file with my text editor, then re-enter Julia REPL. This all works, but wondering if itβs possible to somehow edit that .jl file without leaving the REPL? I imagine I would need a text editor or vim or nano - is there anything like that actually IN the REPL? Or can I switch to shell and get into Linux file sys that way? Thanks for your time guys.
Can you not run a text editor on the HelloWorld.jl file as a separate process, and just move your mouse to switch focus between the two? Or are you not running a windowing system?
VSCode is recommended by many and me.
Of course it has its own learning curve. Perhaps itβs better to start as you do, you may use multiple terminals, one with Julia, another with your editor, another for commands,β¦ and when you feel good you may start again with VSCode.
Another important recommendation is to use Revise.jl , this is to overcome most of the problems if you need to reload a Julia file in the REPL which you have changed.
There are ways to get it done with multiple terminals / windows. But I donβt like going to the mouse and prefer doing everything from the terminal. REPL is running in the terminal and using Linux commands like pwd and cd, and hitting the semicolon opens my actual Linux shell - I think I can get in and out of nano or vim that way. Thanks for your suggestion though.
help?> edit
search: edit @edit timedwait endswith redirect_stdio
edit(path::AbstractString, line::Integer=0, column::Integer=0)
Edit a file or directory optionally providing a line number to
edit the file at. Return to the julia prompt when you quit the
editor. The editor can be changed by setting JULIA_EDITOR,
VISUAL or EDITOR as an environment variable.
See also define_editor.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
edit(function, [types])
edit(module)
Edit the definition of a function, optionally specifying a
tuple of types to indicate which method to edit. For modules,
open the main source file. The module needs to be loaded with
using or import first.
β Julia 1.1
β
β edit on modules requires at least Julia 1.1.
To ensure that the file can be opened at the given line, you
may need to call define_editor first.
Also in a Linux terminal you can press Ctrl-z to suspend Julia. Then edit your file or do whatever. Then type fg to foreground your Julia process again. Also see the Bash jobs command. Combined with Revise.jl this creates a nice workflow.
Also check out the Unix utilities screen and tmux.
I like to use really simple text editors like xed or nano, rather than something like VS Code so Iβm focused on learning the language and not distracted by using a mouse or IDE. Since asking this question I see how easy it is to hit the semicolon key and get into the my Linux file system to use those editors. But thanks - you gave me a lot of other options to try out!
On most OSs you can use ALT+TAB to switch between windows, so need for a mouse and you can just open a second terminal and edit your code in whatever editor you like there.
Thanks - good shortcut, but Iβve figured out since posting this question that when in REPL, if I just open shell with semicolon key I can navigate between Linux file system and REPL without windows. Great feature from the Julia team - works with Linux OS anyway.
Youβre absolutely right to recommend Vim to me - I know that for those who like doing as much in the terminal as possible, Vim is the way. I just havenβt been able to fight the learning curve and stay with it enough to get proficient - but Iβm going to learn it. Thanks for the push,
For someone who wants to stay as log as possible in the terminal, Iβd really second this recommendation.
The idea is that youβd launch the multiplexer in your terminal (either screen or tmux; the latter seems more popular these days), and then you get something akin to multiple βtabsβ or βpanesβ. Youβd open your editor (xed or nano if youβre used to them) in one tab/pane, and the Julia REPL in another. The multiplexer lets you easily switching between tabs/panes.
More advanced editors, such as Emacs (but maybe vim can as well; I just donβt know) can act as sort of a multiplexer in themselves. That is to say you can open a terminal within Emacs, and switch between editing files or interacting with the terminal seamlessly, only using builtin commands. Of course this again is something to learn, but there are many collateral benefits. For example, the ability to interactively select code from a source file and evaluate it inside the Julia REPL (like youβd do in VScode)