Skip to content

Latest commit

 

History

History
138 lines (111 loc) · 5.88 KB

vscode.md

File metadata and controls

138 lines (111 loc) · 5.88 KB

Setting up VSCode

The sections below detail the steps to implement a clean VSCode install, with some useful extensions, settings, and shortcuts.


Install required software

Extensions

Useful VSCode extensions - you can see your installed extensions on the Extensions section of the navigation bar on the left-hand side (you can also open it with Ctrl+Shift+X):

  • Coding

    • Python (this should also install Pylance, Python Debugger, and Python Environments)
    • Jupyter (this should also install Jupyter Cell Tags, Jupyter Keymap, Jupyter Notebook Renderers, Jupyter Slide Show)
    • Docker (this should also install Container Tools)
    • Dev Containers (for developing inside Docker containers directly from VSCode)
    • Black Formatter and isort (extensions for formatting and import organization support for Python files)
    • Data Wrangler
    • Even Better TOML (syntax highlighting and validation for pyproject.toml and other TOML files)
    • R by REditorSupport (language support, syntax highlighting, and IntelliSense for R files)
  • Version control

    • GitHub Pull Requests
    • GitLens
  • Aesthetics

    • Brackets Light Pro
    • Markdown All in One
    • Theme Switcher
    • vscode-icons
    • vscode-pdf

Settings

Default terminal

If using VSCode on Windows, make sure you select Cmd as your default terminal.

  • To do this, open the Command Palette in VSCode with Ctrl+Shift+P. Type in >Terminal: Select Default Profile and choose Command Prompt.

Workspace vs User settings

VSCode has two levels of settings:

  • User settings (settings.json) apply globally to every project you open. These are the settings modified via Ctrl+Shift+P → >Preferences: Open User Settings (JSON) and are stored in your OS user profile.
  • Workspace settings (.vscode/settings.json at the project root) apply only to that project and override User settings when the project is open. Because they live inside the project folder, they can be committed to the repository so the whole team shares the same VSCode configuration for that project.

See python_uv.md for an example of a workspace settings.json that configures the Python interpreter path for a specific project.

User settings

You can modify your settings in VSCode with Ctrl+Shift+P and typing in >Preferences: Open User Settings (JSON).

The settings.json below worked as of Visual Studio Code 1.112. Settings may evolve across versions - check for deprecated keys if you notice any warnings after upgrading.

{
    "editor.wordWrap": "on",
    "editor.bracketPairColorization.independentColorPoolPerBracketType": true,
    "editor.rulers": [80, {"column": 120, "color": "#ffcc00"}],
    "files.autoSave": "onFocusChange",
    "gitlens.ai.model": "vscode",
    "gitlens.ai.vscode.model": "copilot:gpt-4.1",
    "notebook.lineNumbers": "on",
    "security.workspace.trust.untrustedFiles": "open",
    // "themeswitcher.utcOffset": 1,
    // "themeswitcher.mappings": [
    //     {
    //         "time": "06:00",
    //         "theme": "Solarized Dark"
    //     },
    //     {
    //         "time": "07:00",
    //         "theme": "Brackets Light Pro"
    //     },
    //     {
    //         "time": "18:30",
    //         "theme": "Solarized Dark"
    //     }
    // ],
    "telemetry.telemetryLevel": "off",
    "terminal.integrated.defaultProfile.windows": "Command Prompt",
    "terminal.integrated.enableMultiLinePasteWarning": "never",
    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": "C:\\WINDOWS\\System32\\cmd.exe",
            "args": []
        },
        "Git Bash": {
            "source": "Git Bash",
            "icon": "terminal-git-bash"
        }
    },
    "workbench.iconTheme": "vscode-icons",    
    "workbench.sideBar.location": "left",
    "workbench.colorTheme": "Solarized Dark",
}

Shortcuts

  • Ctrl+Shift+P: open the Command Palette in VSCode
  • Ctrl+P: quick file open (fuzzy search across all files in the workspace)
  • Ctrl+Shift+F: search across all files in the workspace
  • Ctrl+Shift+V: preview a markdown file
  • Ctrl+b: toggle left sidebar on/off (or make selection bold if in a .md file)
  • Ctrl+/: toggle line comment on/off
  • Ctrl+D: select the next occurrence of the current selection (repeat to select more; useful for multi-cursor editing)
  • Alt+Up / Alt+Down: move the current line (or selected lines) up or down
  • Alt+Click: place an additional cursor at the click position (multi-cursor)
  • F2: rename a symbol across all usages in the file (works with Pylance, the R extension, and other language extensions)
  • Ctrl+K Ctrl+0: fold (collapse) all code sections
  • Ctrl+K Ctrl+J: unfold (expand) all code sections
  • Ctrl+': open/close terminal in VSCode

Note

Ctrl+' for the terminal is a custom keybinding - the VSCode default is Ctrl+`. To set or change a keybinding, open the Command Palette with Ctrl+Shift+P and type >Preferences: Open Keyboard Shortcuts. Search for the command you want (e.g. Terminal: Toggle Terminal) and click the pencil icon to assign a new key combination.