Run full code on VSCode

I am still new to the community so if I got this in the wrong section I do apologise.

I am using VS Code to edit my Julia programs but from what I can tell I can either run individual lines or code blocks. While these blocks do help me to visualise what my program is doing I cannot seem to work out how to run the entire program from beginning to end.

–Edit
I should point out that I normally edit Python stuff in Sublime Text so Studio Code is a bit of a new bit of software for me. While I have grasped it main use this seems to elude me. :pleading_face:

Do I treat it all as one “block” and then use something like Jupyter when I want to present my explorations or is there a key command that I have not found?

Thank you in advance.

1 Like

You already seem to have figured out how to send code from a file within VS Code to the integrated REPL via Ctrl + Enter (for single lines or selected lines) or Shift + Enter (for code blocks divided by ##).

You can either do Ctrl + A Ctrl + Enter to send the whole content of a file to the Julia REPL. (Quick and simple solution without changing your workflow much.)

Or you could follow these two steps that also do what you want:

  1. Open the Julia REPL in VS Code via Alt+J Alt+O.
  2. Execute include("myfile.jl") inside the REPL.

Make sure your current working directory is correct. Exchange “myfile.jl” with whatever your file is called. You can also pass a full file path (e.g. "../../path/to/file/myfile.jl") to the include function. This is useful if you want to access files in another directory than your current working directory but without changing it via cd() first.

Done. :slight_smile: Does this do what you want?

4 Likes

Thank you for the reply. This has solved my issue :slightly_smiling_face: I am still learning a lot with this language (like been able to use the unicode version of Pi in my calculations has seriously blown my mind). Thank you for been patient with a newbie.

Another method to send the entire edit buffer to the Julia REPL: Note that in the upper right-hand corner of the VSCode window there are a few icons, including \triangleright. Hovering your cursor over this symbol reveals its function: “Julia: Execute File”. Clicking it sends the entire file being displayed to the REPL.

4 Likes

Thank you. I never noticed that button :confounded: and it is now added to my mental notes.

(Honestly I like this community. Everyone I have interacted with so far has been kind)

4 Likes