Skip to content

Latest commit

 

History

History
234 lines (171 loc) · 7.42 KB

README.md

File metadata and controls

234 lines (171 loc) · 7.42 KB

pycharm-to-vscode-transition

Make a smooth transition from slow and heavy PyCharm to fast and light VSCode.

Table of Contents

  • — Command (Ctrl on Windows/Linux)
  • — Ctrl
  • — Option / Alt
  • — Shift

Extensions

Semantic & Linting Highlighting, Templates & RegEx support and more.

See Keybinds to learn more.

PyColonize — automatically add colon at the end of the line

animated

  • 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'"
    },

Helpers

Settings

Linting highlights

    "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",

Enable indexing (better auto -suggestions and -import)

    "python.analysis.indexing": true,

Increase depths for import suggestions

    "python.analysis.packageIndexDepths":[
            ["", 2],
            ["package_name", 3],
    ],

Note: Requires Pylance, explanation: microsoft/pylance-release#291 (comment)

Make speed scroll closer to one in PyCharm

    "editor.mouseWheelScrollSensitivity": 0.35,

Tested on MacBook's touchpad

    "editor.fontFamily": "JetBrains Mono",

Note: download and install it on your system first

Adjust line height

    "editor.lineHeight": 1.7, // matches PyCharm with JetBrains Mono

Note: tested with JetBrains Mono font

Adjust letter spacing

    "editor.letterSpacing": -0.4, // matches PyCharm with JetBrains Mono

Note: tested with JetBrains Mono font

Enable auto save for files

    "files.autoSave": "afterDelay",

Add project root, src and tests dir to PYTHONPATH by default

    "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>

Use black formatter by default

    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
    },

Note: requires Black Formatter extension.

Keybinds

Fix IntelliJ IDEA Keybinds extension

Remove it's bind for K as it's a special combination in VSCode

    {
        "key": "cmd+k",
        "command": "-git.commitAll",
        "when": "!inDebugMode && !terminalFocus",
    },

Add line below and move cursor down

    {
        "key": "cmd+enter",
        "command": "editor.action.insertLineAfter",
        "when": "editorTextFocus && !editorReadonly && editorLangId != 'python'",
    },

Note: for auto colons see Extensions -> PyColonize

Comment line and move cursor down

    {
        "key": "cmd+/",
        "command": "extension.multiCommand.execute",
        "args": {
          "sequence": [
            "editor.action.commentLine",
            "cursorDown"
          ]
        },
        "when": "editorTextFocus && !editorReadonly"
      },

Note: requires multi-command extension.

Paste and indent

    {
        "key": "cmd+v",
        "command": "pyPasteIndent.pasteIndent",
        "when": "editorTextFocus && !editorReadonly && editorLangId == 'python'"
    },

Note: requires Python Paste And Indent extension.