Class Notes: Getting Started with Visual Studio Code (VSCode)


Important note: When you are done with these instructions, do not run your code using the green triangular Run button (since that fails in some cases in this setup). Instead, to run your code, press cmd+b or ctrl+b.

  1. Install Python 3.10.x from python.org's download page. If you are installing on Windows, be sure to check the box that adds Python to your PATH!


  2. Install and run VSCode from here


  3. Click on the 'Extensions' tab on the left toolbar


  4. Type 'Python' into the search bar and install the extension by Microsoft named simply 'Python'

    Note: What you see on your screen might look slightly different from our screenshots (colors, icons, etc.) depending on your operating system, updates, and cosmetic settings.


  5. Type 'multi-command' into the search bar and install the multi-command extension


  6. If you haven't already created a folder for 15-112, do that in a convenient location on your computer. Next, download helloWorld.py and put it in that folder.


  7. In VSCode, open helloWorld.py (using File > Open), then look at this text (or similar text) in the bottom right hand corner of the screen

    If the text says 'Python 3.10.x' you're set! If not, click on the text. A dropdown will appear, then select 'Python 3.10.x' (where 'x' is some number, i.e. 3.10.6)


  8. Click 'cmd + shift + p' (Mac) or 'ctrl + shift + p' (Windows) to open the 'Command Palette'.


  9. Type in 'settings' then click on 'Preferences: Open User Settings (JSON)' (or 'Preferences: Open Settings (JSON)' if you see that instead)


  10. Paste these settings into the page that opens up (replacing the settings that are there) and hit save..
    
    {
        "window.zoomLevel": 0,
        "editor.fontSize": 18,
        "terminal.integrated.fontSize": 18,
    
        "python.terminal.executeInFileDir": true,
        "python.terminal.launchArgs": ["-i"],
        "python.linting.pylintEnabled": false,
    
        "editor.quickSuggestions": {
            "other": false,
            "comments": false,
            "strings": false
        },
        "editor.acceptSuggestionOnEnter": "off",
        "editor.quickSuggestionsDelay": 10,
        "editor.wordBasedSuggestions": false,
        "editor.parameterHints.enabled": false,
        "editor.rulers": [80],
    
        "multiCommand.commands": [
            {
                "command": "multiCommand.runPythonREPL",
                "interval": 100,
                "sequence": [
                    "workbench.action.terminal.kill",
                    "python.execInTerminal",
                ]
            }
        ],
    }
        


  11. Reopen the Command Palette. This time, type in 'Keyboard Shortcuts' and click on 'Preferences: Open Keyboard Shortcuts (JSON)'


  12. Paste these settings into the page that opens up (replacing the settings that are there) and hit save.
    
    [
        { "key": "cmd+b", "command": "multiCommand.runPythonREPL" },
        { "key": "ctrl+b", "command": "multiCommand.runPythonREPL" },
    ]
        


  13. Make VSCode the default editor on your computer.
    Mac:
    1. Open Finder
    2. Right click on a Python file
    3. Choose 'Get Info'
    4. Set 'Open With' to VSCode
    5. select 'Change All'
    Windows:
    1. Open File Explorer
    2. Right click on a Python file
    3. Choose 'Open With' > 'Choose Default Program'
    4. Set 'Opens With' to VSCode


  14. Restart VSCode, and now you're ready to go!

    Important note: When you are done with these instructions, do not run your code using the green triangular Run button (since that fails in some cases in this setup). Instead, to run your code, press cmd+b or ctrl+b.