Using VSCode

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

  1. First install Anaconda and VSCode according to my notes (if you have not done so already). When you install VSCode, 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 VSCode (it looks like four little boxes) and then searching the marketplace for "Python."

  2. For this course always launch VSCode from the Anaconda Navigator. This ensures the environment is set up correctly for using Anaconda. This might not be strictly necessary, but the VSCode 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 VSCode can also clone Git repositories. In VSCode 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 VSCode and run it. In VSCode 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 VSCode 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. Checkout the main branch and verify that your change is no longer visible.

  11. Checkout 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: 2022-06-27
© Copyright 2022 by Peter Chapin <>