CMU 15-112: Fundamentals of Programming and Computer Science
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.
Install Python 3.9
  1. Install Python 3.9.x from python.org's download page
    • If you're on a Windows computer, you probably want "Windows x86-64 executable installer".

Install VSCode
  1. Install and run VSCode from here


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


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


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


  5. Open any Python file (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.9.x' you're set! If not, click on the text. A dropdown will appear, then select 'Python 3.9.x'


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


  7. Type in 'Settings' then click on 'Preferences: Open Settings (JSON)'


  8. Paste these settings into the page that opens up (replacing the settings that are there) and hit save.
    
    {
        "window.zoomLevel": 0,
        "editor.fontSize": 16,
        "terminal.integrated.fontSize": 16,
    
        "python.terminal.executeInFileDir": true,
        "python.terminal.launchArgs": ["-i"],
        "python.linting.pylintEnabled": false,
    
        "editor.quickSuggestions": 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",
                ]
            }
        ],
    }
        


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


  10. 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" },
    ]
        


  11. 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


  12. 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.