Setting run/build target?

Most of the time, my workflow is something like

  1. Write module
  2. Write script calling functions in module
  3. Run script and get an error in a function in the module
  4. Fix error
  5. Repeat steps 3-4 forever

The problem is that after fixing the function error, every single time I have to click back to my script and run it. Because of the way VS Code opens tabs, it never stays put where I expect it, and even if it did, inevitably there’s a new error in the same function I was just in, so I end up having to click back and forth.

What I’d like to be able to do is to designate a script as my “build target” and then have a global keyboard shortcut that runs that file (i.e. “Execute file in REPL” but a pre-specified file, not an active file). That way when I fix the function, I could stay in that file, smash some shortcut, and have my script run, and then already be in the right file to fix the next error.

I don’t mind too much going into the settings and manually editing the path target file every once in a while, but it’d be nicer if there were also a shortcut that did “Designate this file as the build target.”

How would I do this?

(I’m also open to completely new workflow suggestions)

2 Likes

My workflow is to have my active Julia session up and type include("path/to/script.jl"). Then rerunning is just CTRL+J to open the terminal, up arrow then enter to run my last command. I use Revise to make sure the module stays up to date.

A Revise based workflow really helps.

  1. Load the module as package via using.
  2. Turn the script into a function.
  3. Include the script via Revise.includet which is exported.

Now each iteration just requires you to rerun the function in the REPL. Chnages to module and function will be updated automatically before each REPL command.