- Notes on VSCode
- Contents
- Installed extensions
settings.json
keybindings.json
./.vscode/settings.json
(workspace settings, includingpytestArgs
andpython.analysis.extraPaths
)./.vscode/c_cpp_properties.json
(C/C++ language settings, including#define
macros,#include
paths, and the compiler path)./.vscode/launch.json
(debugging configurations, including for Python and for C)./.vscode/tasks.json
(task configurations, used as build commands for debugging configurations)
Installed extensions can be listed on the command line using the command code --list-extensions
. Below are the extensions I regularly use:
eamodio.gitlens
mhutchie.git-graph
ms-python.python
ms-vscode.cpptools
ms-vscode.hexeditor
PKief.material-icon-theme
stkb.rewrap
v4run.transpose
yzhang.markdown-all-in-one
To install an extension from the command line, use the code --install-extension
command, EG code --install-extension eamodio.gitlens
.
Below are some old extensions I have used in the past:
tomoki1207.pdf
yzane.markdown-pdf
donjayamanne.githistory
DavidAnson.vscode-markdownlint
fabiospampinato.vscode-diff
Gimly81.matlab
jack89ita.open-file-from-path
johnstoncode.svn-scm
oliversturm.fix-json
Useful commands using the "Markdown All in One" extension:
- Markdown: Open Locked Preview to the Side
- Markdown All in One: Create Table of Contents
- Markdown All in One: Update Table of Contents
For more information about C/C++ default include-paths in VSCode, and how to combine them with local settings, see Customizing default settings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "alt+c",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+c",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+alt+c",
"command": "copyRelativeFilePath",
},
{
"key": "ctrl+shift+alt+c",
"command": "copyFilePath",
},
{
"key": "alt+r",
"command": "python.execInTerminal",
"when": "editorTextFocus"
},
{
"key": "ctrl+r",
"command": "workbench.action.terminal.runSelectedText",
"when": "editorTextFocus"
},
{
"key": "shift+alt+r",
"command": "revealFileInOS",
},
{
"key": "ctrl+alt+r",
"command": "workbench.files.action.showActiveFileInExplorer",
},
{
"key": "alt+s",
"command": "extension.transpose",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+s",
"command": "editor.action.insertCursorAtEndOfEachLineSelected",
"when": "editorTextFocus"
},
{
"key": "ctrl+d",
"command": "compareSelected"
},
{
"key": "alt+d",
"command": "editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "shift+alt+d",
"command": "workbench.action.duplicateWorkspaceInNewWindow",
},
{
"key": "alt+t",
"command": "workbench.action.terminal.toggleTerminal",
},
{
"key": "shift+alt+t",
"command": "openInTerminal",
},
{
"key": "alt+m",
"command": "workbench.action.toggleMaximizedPanel",
},
{
"key": "alt+k",
"command": "workbench.action.terminal.kill"
},
{
"key": "alt+a",
"command": "git.stageSelectedRanges",
},
{
"key": "alt+u",
"command": "git.unstageSelectedRanges",
},
{
"key": "alt+v",
"command": "git.revertSelectedRanges",
},
{
"key": "alt+n",
"command": "workbench.action.editor.nextChange",
"when": "editorTextFocus"
},
{
"key": "alt+n",
"command": "workbench.action.compareEditor.nextChange",
"when": "textCompareEditorVisible"
},
{
"key": "alt+b",
"command": "workbench.action.editor.previousChange",
"when": "editorTextFocus"
},
{
"key": "alt+b",
"command": "workbench.action.compareEditor.previousChange",
"when": "textCompareEditorVisible"
},
{
"key": "ctrl+b",
"command": "editor.action.selectToBracket",
},
{
"key": "ctrl+f5",
"command": "workbench.action.reloadWindow",
"when": "editorTextFocus"
},
{
"key": "shift+alt+down",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+up",
"command": "editor.action.copyLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt+left",
"command": "workbench.action.navigateBack"
},
{
"key": "alt+right",
"command": "workbench.action.navigateForward"
},
]
These are the workspace settings, included here in particular for the pytestArgs
, and also for "python.analysis.extraPaths"
, which allows paths to imported modules to be specified so that Pylance does not think they are missing
{
"python.pythonPath": "env\\Scripts\\python.exe",
"python.testing.pytestArgs": [
".",
"-o", "junit_family=xunit1",
"--durations=5",
// "-s"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.extraPaths": ["Scripts"]
}
./.vscode/c_cpp_properties.json
(C/C++ language settings, including #define
macros, #include
paths, and the compiler path)
{
"configurations": [
{
"name": "Win32",
"compilerPath": "C:\\cygwin64\\bin\\gcc.exe",
"includePath": [
"${workspaceFolder}/**",
"C:/Program Files/MATLAB/R2019b/extern/include",
"C:/Program Files/MATLAB/R2020a/extern/include",
"C:/Program Files/MATLAB/R2020a/sys/lcc64/lcc64/include64"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"_GNU_SOURCE"
],
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
},
{
"name": "Python, including stepping into external libraries",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false,
},
{
"name": "Specific Python script with args",
"type": "python",
"request": "launch",
"program": "path/to/Python/script.py",
"console": "integratedTerminal",
"args": ["--arg_1_name", "arg_2_name", "-etc"]
},
{
// Remember to pass the -g flag to gcc when compiling
"name": "Debug C executable",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/path/to/executable",
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"preLaunchTask": "custom_build_task"
}
]
}
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "custom_build_task",
"type": "shell",
"command": "gcc /path/to/source/file -o /path/to/executable -g"
}
]
}