Make a smooth transition from slow and heavy PyCharm to fast and light VSCode.
- Extensions
- Settings
- Linting highlights
- Enable indexing (better auto -suggestions and -import)
- Increase depths for import suggestions
- Make speed scroll closer to one in PyCharm
- Use JetBrains Mono Font
- Adjust line height
- Adjust letter spacing
- Enable auto save for files
- Add project root, src and tests dir to
PYTHONPATH
by default - Use black formatter by default
- Keybinds
⌘
— Command (Ctrl on Windows/Linux)⌃
— Ctrl⌥
— Option / Alt⇧
— Shift
Semantic & Linting Highlighting, Templates & RegEx support and more.
See Keybinds to learn more.
PyColonize — automatically add colon at the end of the line
⌘
Enter
— add colon and continue on the new line⇧
Enter
— add colon and continue on the same line⌘
⌥
Enter
— add colon and stay at the same position
By default shortcut will work only with Python files. If you want to mimic this behaviour in other languages as well, but without a colon, add following to keybindings.json
:
{
"key": "cmd+enter",
"command": "editor.action.insertLineAfter",
"when": "editorTextFocus && !editorReadonly && editorLangId != 'python'"
},
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
// - highlights
// Pycharm has Error, Warning, Weak Warning
// VSCode has Error, Warning, Information
// TODO: This should be better adjusted
"python.linting.flake8CategorySeverity.F": "Information",
"python.linting.flake8CategorySeverity.E": "Warning",
"python.linting.flake8CategorySeverity.W": "Information",
"python.linting.mypyCategorySeverity.note": "Information",
"python.linting.mypyCategorySeverity.error": "Information",
"python.linting.pycodestyleCategorySeverity.E": "Information",
"python.analysis.indexing": true,
"python.analysis.packageIndexDepths":[
["", 2],
["package_name", 3],
],
Note: Requires Pylance, explanation: microsoft/pylance-release#291 (comment)
"editor.mouseWheelScrollSensitivity": 0.35,
Tested on MacBook's touchpad
Use JetBrains Mono Font
"editor.fontFamily": "JetBrains Mono",
Note: download and install it on your system first
"editor.lineHeight": 1.7, // matches PyCharm with JetBrains Mono
Note: tested with JetBrains Mono font
"editor.letterSpacing": -0.4, // matches PyCharm with JetBrains Mono
Note: tested with JetBrains Mono font
"files.autoSave": "afterDelay",
"terminal.integrated.env.osx": {
"PYTHONPATH": "${workspaceFolder}:${workspaceFolder}/src:${workspaceFolder}/tests"
},
"code-runner.executorMap": {
"python": "PYTHONPATH=${workspaceFolder}:${workspaceFolder}/src:${workspaceFolder}/tests ${pythonPath} -u ${fullFileName}"
},
"python.envFile": "~/.vscode/.env",
Then create ~/.vscode/.env
:
PYTHONPATH=${env:PROJ_DIR}:${env:PROJ_DIR}/src:${env:PROJ_DIR}/tests:${env:PYTHONPATH}
Note: change colons to semicolons on Windows and .osx
to .<your system>
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
},
Note: requires Black Formatter extension.
Remove it's bind for ⌘
K
as it's a special combination in VSCode
{
"key": "cmd+k",
"command": "-git.commitAll",
"when": "!inDebugMode && !terminalFocus",
},
{
"key": "cmd+enter",
"command": "editor.action.insertLineAfter",
"when": "editorTextFocus && !editorReadonly && editorLangId != 'python'",
},
Note: for auto colons see Extensions -> PyColonize
{
"key": "cmd+/",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"editor.action.commentLine",
"cursorDown"
]
},
"when": "editorTextFocus && !editorReadonly"
},
Note: requires multi-command extension.
{
"key": "cmd+v",
"command": "pyPasteIndent.pasteIndent",
"when": "editorTextFocus && !editorReadonly && editorLangId == 'python'"
},
Note: requires Python Paste And Indent extension.