Skip to content

Instantly share code, notes, and snippets.

@guimondmm
Created June 10, 2022 16:27
Show Gist options
  • Save guimondmm/53e94496ce2036f7dc9e728338b178e3 to your computer and use it in GitHub Desktop.
Save guimondmm/53e94496ce2036f7dc9e728338b178e3 to your computer and use it in GitHub Desktop.
VS Code workspace template for Jupyter notebooks: a mix of "sane" defaults and personal preferences (edit as needed)
{
"folders": [
{
"path": "."
}
],
"settings": {
"editor.bracketPairColorization.enabled": false,
"editor.fontFamily": "Iosevka, Consolas, 'Courier New', monospace",
"editor.fontLigatures": true,
"workbench.colorTheme": "Cobalt2",
"workbench.iconTheme": "vscode-icons",
"workbench.editorAssociations": {
"*.csv": "gc-excelviewer-csv-editor",
"*.md": "vscode.markdown.preview.editor",
},
"autoDocstring.docstringFormat": "sphinx",
"autoDocstring.guessTypes": true,
"terminal.integrated.defaultProfile.windows": "Anaconda PowerShell Prompt",
"terminal.integrated.profiles.windows": {
"Anaconda PowerShell Prompt": {
"path": "pwsh.exe",
"args": [
"-ExecutionPolicy",
"ByPass",
"-NoExit",
"-Command",
"& '${env:USERPROFILE}\\anaconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate '${env:USERPROFILE}\\anaconda3' ",
],
},
},
"vsintellicode.features.apiExamples": "enabled",
"vsintellicode.features.python.deepLearning": "enabled",
},
"extensions": {
"recommendations": [
"grapecity.gc-excelviewer",
"kevinrose.vsc-python-indent",
"leonhard-s.python-sphinx-highlight",
"ms-python.gather",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"ms-toolsai.vscode-jupyter-powertoys",
"njpwerner.autodocstring",
"visualstudioexptteam.intellicode-api-usage-examples",
"visualstudioexptteam.vscodeintellicode-completions",
"visualstudioexptteam.vscodeintellicode",
"vscode-icons-team.vscode-icons",
"wesbos.theme-cobalt2",
]
}
}
@guimondmm
Copy link
Author

Prerequisites

How to use

  1. Tweak the configuration to your liking in your text editor of choice (it's literally just a JSON file with a different extension)
  2. Place the file at the root of the folder containing all your Jupyter notebooks
  3. Double-click it to open the workspace in VS Code
  4. Trust the workspace
    Trust nobody not even yourself
  5. Install the recommended extensions when prompted (or don't)
  6. Reload VS Code if needed to activate the extensions

This workspace's default terminal profile launches PowerShell with exactly the same command as Anaconda Navigator does. That is to say, it sources %USERPROFILE%\anaconda3\shell\condabin\conda-hook.ps1, which sets the required environment variables, and activates the base Conda environment. This means you don't need to add Conda to PATH to use Conda in VS Code's terminal. On my system, it's also much faster to launch PowerShell this way than if you let conda init fiddle with your PowerShell profile.

You may wonder why I chose Cobalt2 as the workspace's default theme. It's because VS Code themes weren't built with Jupyter notebooks in mind. Nearly all themes make code cells way too low contrast to read comfortably. In my opinion, Cobalt2's titular cobalt blue background is one of the handful few with decent notebook code cell legibility out of the box. But IDE colour schemes are a contentious topic, I know. Change it if you don't like it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment