Using VS Code

This document contains a list of things to try with VS Code. If you can work through this list you should be in good shape for using this powerful tool.

  1. First, install Anaconda and VS Code according to my notes (if you have not done so already). When you install VS Code, be sure to specify that you plan to use the Python programming language. It will ask you about this the first time you run it. If you forget to do this, you can install the Python extension later by clicking on the extension tab on the left side of VS Code (it looks like four little boxes) and then searching the marketplace for "Python."

  2. For this course always launch VS Code from the Anaconda Navigator. This ensures the environment is set up correctly for using Anaconda. This might not be strictly necessary, but the VS Code documentation recommends it.

  3. Clone whatever Git repository you are using from GitHub. The GitHub Desktop tool is a good way to do this, but VS Code can also clone Git repositories. In VS Code be sure no folder is currently open ("File -> Close Folder" on the main menu if necessary), and then click on the "Source Control" tab on the left side (it looks like two diverging paths).

  4. Take note of which Git branch you are on in the lower left corner (should be "main"). Change the Python interpreter, if necessary, to be the one in Anaconda.

  5. Pull the latest updates to the main branch from GitHub by clicking on the three dots in the "Source Control" tab and selecting "Pull." You should already have the latest version since you just cloned the repository, but you should familiarize yourself with how you can get updated material.

  6. Open a suitable sample program from the repository clone in VS Code and run it. In VS Code, first click on the "Run and Debug" tab on the left (it looks like a beetle with an arrow head). I recommend using the main menu "Run -> Run Without Debugging" to run the program (instead of using the obvious green arrow... that runs the debugger).

  7. Go back to the "Source Control" tab and create a branch in your local repository for your experimentation. Call your branch something like "sandbox." Notice that VS Code switches to the new branch automatically (check in the lower left corner).

  8. Make a simple change to the program such as printing an additional line. Run the program to verify that your change is working.

  9. Commit your change to your branch by clicking on the check mark at the top of the window (in the "Source Control" tab). Be sure to specify a meaningful commit log message that describes your change.

  10. Check out the main branch and verify that your change is no longer visible.

  11. Check out the sandbox branch again and verify that your change is once again visible. I recommend creating a branch for each homework assignment. However, be sure you are always on the main branch when you create a new branch. Also, be sure you are always on the main branch when you pull my changes from GitHub.

    Be aware that the branches you create this way are on your machine and not on the server. You may want to back up your local repository. Let me know if you need more advice about how to do this.

  12. If you want, you can delete the sandbox branch. This will remove all changes made to that branch. No other branch will be affected. There is no reason why you have to delete sandbox, except if you just like keeping things as tidy as possible.


Last Revised: 2025-01-09
© Copyright 2025 by Peter Chapin <peter.chapin@vermontstate.edu>