Skip to content

Instantly share code, notes, and snippets.

@jmsdnns
Last active January 7, 2024 23:30
Show Gist options
  • Save jmsdnns/26b9ce79bb420cb900103e4e9b82c8c6 to your computer and use it in GitHub Desktop.
Save jmsdnns/26b9ce79bb420cb900103e4e9b82c8c6 to your computer and use it in GitHub Desktop.

Tips for using Python with VSCode

Open VSCode from Terminal

In VSCode, open the command palette with: Command + Shift + P

Then type: shell command and choose install 'code' command in PATH

Open VSCode in venv

Create a virtual environment for your project: python -mvenv venv.

Then: pip install jupyter graphviz black and anything else you need.

Then open code with the virtualenv enabled and vscode will use your venv for everything, including code formatting tools

Add Extensionts to VSCode

Two main extensions, both from Microsoft:

  • Python
  • Black Formatter

Black will assume you have the black python module installed into your environment, so always do the virtualenv part first.

My fav VSCode Settings

{
    /* App */
    "workbench.iconTheme": null,
    "workbench.tree.indent": 17,
    "workbench.startupEditor": "newUntitledFile",
    "workbench.editor.enablePreview": false,
    "workbench.editor.enablePreviewFromQuickOpen": false,
    "keyboard.dispatch": "keyCode",
    "window.openFoldersInNewWindow": "on",
    "window.menuBarVisibility": "toggle",

    /* Editor */
    "editor.fontSize": 15,
    "editor.lineHeight": 17,
    "editor.letterSpacing": -0.2,
    "editor.renderLineHighlight": "gutter",
    "editor.guides.indentation": false,
    "editor.bracketPairColorization.enabled": false,
    "editor.folding": false,
    "editor.detectIndentation": false,
    "editor.minimap.enabled": false,
    "breadcrumbs.enabled": false,
    "editor.parameterHints.enabled": false,
    "editor.renderControlCharacters": false,
    "editor.autoClosingBrackets": "never",
    "editor.autoClosingQuotes": "never",
    "editor.quickSuggestionsDelay": 300,
    "editor.quickSuggestions": {
        "other": false,
        "comments": false,
        "strings": false
    },

    /* Terminal */
    "terminal.integrated.fontSize": 15,
    "terminal.integrated.fontWeightBold": "normal",
    "terminal.integrated.drawBoldTextInBrightColors": false,
    "terminal.integrated.allowChords": false,
    "terminal.integrated.scrollback": 10000,
    "terminal.integrated.shellIntegration.enabled": false,
    "terminal.integrated.shellIntegration.history": 0,
    "terminal.integrated.enableImages": true,
    "terminal.integrated.enableMultiLinePasteWarning": false,

    /* Files */
    "files.saveConflictResolution": "overwriteFileOnDisk",
    "files.insertFinalNewline": true,
    "explorer.excludeGitIgnore": true,
    "files.exclude": {
        "build": true,
        "**/*.swp": true,
        "**/.vscode": true,
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true
    },

    /* Leave me alone */
    "security.workspace.trust.banner": "never",
    "security.workspace.trust.enabled": false,
    "update.showReleaseNotes": false,
    "extensions.ignoreRecommendations": true,
    "telemetry.telemetryLevel": "off",
    "typescript.surveys.enabled": false,
    
    /* Debug */
    "debug.openDebug": "neverOpen",
    "debug.internalConsoleOptions": "openOnSessionStart",

    /* Git */
    "git.enabled": false,
    "git.decorations.enabled": false,

    /* Python */
    "python.defaultInterpreterPath": "",
    "python.venvFolders": [
        "venv"
    ],
    "jupyter.experiments.enabled": false,

    /* HTML */
    "html.suggest.html5": false,
    "html.autoClosingTags": false,
    "html.autoCreateQuotes": false,
    "[html]": {
        "editor.tabSize": 2
    },

    /* JS */
    "[javascript]": {
        "editor.tabSize": 2
    },

    /* JSON */
    "[json]": {
        "editor.tabSize": 2
    },

    /* Markdown */
    "markdown.preview.scrollEditorWithPreview": false,
    "markdown.preview.fontSize": 17,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment