VSCode Setup and Usage

Installation

Download from here

Installation Options

  • Accept the default installation path
  • keep “Register Code as an editor for supported file types” checked
  • keep “Add to PATH” checked
  • other options: set to your preference

Ubuntu-specific

cd ~/Downloads
sudo dpkg -i code_1.7* #.... tab complete
sudo apt install -yf

Video

Thanks to Wyatte for this helpful video

Useful command-line arguments

Note: this only works if you added vscode to your system PATH

Usage: code [options][paths...]

Example:

code -n ~/websites/danb0b.github.io/

will open a new folder with that path loaded in the explorer window

  -a --add <folder>      Add folder(s) to the last active window.
  -n --new-window        Force to open a new window.
  -r --reuse-window      Force to open a file or folder in an already opened window.
  --extensions-dir <dir> Set the root path for extensions.
  --list-extensions      List the installed extensions.
  --show-versions        Show versions of installed extensions, when using --list-extensions.
  --install-extension <ext-id | path> Installs or updates an extension. 
  --uninstall-extension <ext-id>      Uninstalls an extension.
  --enable-proposed-api <ext-id>      Enables proposed API features for
  --disable-extensions            Disable all installed extensions.
  --disable-extension <ext-id>    Disable an extension.
  --sync <on | off>               Turn sync on or off.

Shortcuts

Key Combination Description
ctrl+shift+p opens the command window
ctrl+shift+e opens explorer
ctrl+shift+x opens extensions
ctrl+shift+g opens git
ctrl+shift+f opens search
ctrl+shift+k remove line
ctrl+shift+/ comment line:
ctrl+up move line up
ctrl+down move line down
ctrl+k,v preview
ctrl+shift+i format document
ctrl+i italicize selection
ctrl+b bold selection
alt+z switch text wrap mode

Extensions

from here

open a terminal window and paste the following in:

### python support
code --install-extension ms-python.debugpy
code --install-extension ms-python.python
code --install-extension ms-python.vscode-pylance

markdown support

code --install-extension davidanson.vscode-markdownlint
code --install-extension pkief.markdown-checkbox
code --install-extension shd101wyy.markdown-preview-enhanced
code --install-extension bierner.markdown-yaml-preamble
code --install-extension yzhang.markdown-all-in-one

git support

code --install-extension codezombiech.gitignore
code --install-extension donjayamanne.githistory
code --install-extension mhutchie.git-graph
code --install-extension waderyan.gitblame
code --install-extension ziyasal.vscode-open-in-github

esp32 support

code --install-extension pycom.pymakr-preview

misc

code --install-extension streetsidesoftware.code-spell-checker
code --install-extension redhat.vscode-yaml
code --list-extensions

Markdown all-in-one

go to settings @id:editor.defaultFormatter @lang:markdown formatter ctrl_+ shift + I then formats your document

Python

When working with multiple python environments, you should make sure to use the correct one for the task you are doing. To do this, you will need to select from a list of python interpreters. Type ctrl+shift+p then type / select “python select interpreter” from the list.

Debugging Python Code

see this reference to add a debug configuration

Preferences

{
    "workbench.colorTheme": "Default Dark+",
    "git.confirmSync": false,
    "pymakr.devices.configs": {
        "serial:///dev/ttyUSB1": {
            "autoConnect": "onLostConnection",
            "name": "",
            "username": "micro",
            "password": "python",
            "hidden": false,
            "rootPath": null,
            "adapterOptions": {}
        }
    },
    "security.workspace.trust.untrustedFiles": "open",
    "[markdown]": {
        "editor.defaultFormatter": "yzhang.markdown-all-in-one"
    },
    "explorer.confirmDragAndDrop": false,
    "pymakr.misc.notifications": {
        "Uploading a project will delete all existing files on the device before uploading the project folder. After uploading a project, you can start it by restarting the device. For faster uploads without file deletion, please put the device in dev mode.": "Don't show again",
        "ttyUSB0 / unknown seems to be busy. Do you wish restart it in safe mode": "Restart in safe mode",
        "Could not safeboot device. Please hard reset the device and verify that a shield is installed.": "Don't show again",
        "A terminal for ttyUSB0 / unknown already exists.": "No and don't ask again",
        "A terminal for ttyUSB0 / OLED-and-Graphing already exists.": "No and don't ask again",
        "ttyUSB0 / OLED-and-Graphing seems to be busy. Do you wish restart it in safe mode": "No and don't ask again",
        "A terminal for ttyUSB0 / code_esp32_servo_gaits already exists.": "Open existing terminal",
        "ttyUSB0 / danscode seems to be busy. Do you wish restart it in safe mode": "Don't show again",
        "A terminal for ttyUSB0 / danscode already exists.": "No and don't ask again"
    },
    "editor.fontSize": 12,
    "markdownlint.config": {
        "default": true,
        "MD007": { "indent": 4 }
    },
    "markdown.extension.orderedList.autoRenumber": false,
    "markdown.extension.list.indentationSize": "inherit",
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "diffEditor.ignoreTrimWhitespace": false,
    "workbench.startupEditor": "none",
    "extensions.ignoreRecommendations": true,
    "[python]": {
        "editor.formatOnType": true
    },
    "git.enableSmartCommit": true,
    "markdown.experimental.editor.pasteLinks.enabled": false,
    "markdown.extension.italic.indicator": "_",
    "markdown.extension.orderedList.marker": "one",
    "files.hotExit": "off",
    "latex-workshop.message.information.show": true,
    "editor.wordWrap": "on",
    "jupyter.askForKernelRestart": false,
    "explorer.confirmDelete": false,
    "notebook.cellToolbarLocation": {
        "default": "right",
        "jupyter-notebook": "left"
    },
    "editor.defaultFormatter": "yzhang.markdown-all-in-one"

Keyboard Shortcuts


// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "ctrl+down",
        "command": "editor.action.moveLinesDownAction",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "alt+down",
        "command": "-editor.action.moveLinesDownAction",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+up",
        "command": "editor.action.moveLinesUpAction",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "alt+up",
        "command": "-editor.action.moveLinesUpAction",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+2",
        "command": "markdown.extension.editing.toggleList"
    },
    {
        "key": "ctrl+d",
        "command": "editor.action.deleteLines",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+shift+k",
        "command": "-editor.action.deleteLines",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+alt+i",
        "command": "markdownlint.fixAll"
    },
    {
        "key": "ctrl+shift+/",
        "command": "workbench.files.action.collapseExplorerFolders"
    },
    {
        "key": "ctrl+shift+j",
        "command": "markdown-checkbox.markCheckbox",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+enter",
        "command": "-markdown-checkbox.markCheckbox",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+\\",
        "command": "-editor.action.jumpToBracket",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+j",
        "command": "markdown-checkbox.createCheckbox",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+c",
        "command": "-markdown-checkbox.createCheckbox",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+j",
        "command": "-workbench.action.togglePanel"
    },
    {
        "key": "ctrl+shift+j",
        "command": "-workbench.action.search.toggleQueryDetails",
        "when": "inSearchEditor || searchViewletFocus"
    },
    {
        "key": "shift+enter",
        "command": "-python.execSelectionInTerminal",
        "when": "editorTextFocus && !findInputFocussed && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
    }

External Resources