{"id":31384078,"url":"https://github.com/kbrose/vsc-python-indent","last_synced_at":"2025-09-28T14:16:10.439Z","repository":{"id":38154662,"uuid":"176741432","full_name":"kbrose/vsc-python-indent","owner":"kbrose","description":"Correctly indent python code on the fly, in Visual Studio Code.","archived":false,"fork":false,"pushed_at":"2025-02-26T23:00:41.000Z","size":3409,"stargazers_count":102,"open_issues_count":12,"forks_count":21,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-26T04:34:30.528Z","etag":null,"topics":["indentation","python","typescript","visual-studio-code","vscode","vscode-extension"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=KevinRose.vsc-python-indent","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kbrose.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"kbrose","custom":["https://paypal.me/2kbrose"]}},"created_at":"2019-03-20T13:36:27.000Z","updated_at":"2025-09-23T11:27:48.000Z","dependencies_parsed_at":"2024-11-12T20:23:25.348Z","dependency_job_id":"5dd2931b-5b7d-4cd1-a90e-fce1b93db28c","html_url":"https://github.com/kbrose/vsc-python-indent","commit_stats":null,"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"purl":"pkg:github/kbrose/vsc-python-indent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrose%2Fvsc-python-indent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrose%2Fvsc-python-indent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrose%2Fvsc-python-indent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrose%2Fvsc-python-indent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kbrose","download_url":"https://codeload.github.com/kbrose/vsc-python-indent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbrose%2Fvsc-python-indent/sbom","scorecard":{"id":552678,"data":{"date":"2025-08-11","repo":{"name":"github.com/kbrose/vsc-python-indent","commit":"61fe8ded664f2c930d79b785fae76029cc9bd78c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 1/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/kbrose/vsc-python-indent/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/kbrose/vsc-python-indent/ci.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:26","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v1.21.0 not signed: https://api.github.com/repos/kbrose/vsc-python-indent/releases/202673498","Warn: release artifact v1.20.0 not signed: https://api.github.com/repos/kbrose/vsc-python-indent/releases/202673407","Warn: release artifact v1.18.1 not signed: https://api.github.com/repos/kbrose/vsc-python-indent/releases/181147964","Warn: release artifact v1.18.0 not signed: https://api.github.com/repos/kbrose/vsc-python-indent/releases/78897297","Warn: release artifact v1.21.0 does not have provenance: https://api.github.com/repos/kbrose/vsc-python-indent/releases/202673498","Warn: release artifact v1.20.0 does not have provenance: https://api.github.com/repos/kbrose/vsc-python-indent/releases/202673407","Warn: release artifact v1.18.1 does not have provenance: https://api.github.com/repos/kbrose/vsc-python-indent/releases/181147964","Warn: release artifact v1.18.0 does not have provenance: https://api.github.com/repos/kbrose/vsc-python-indent/releases/78897297"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":3,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'main'","Info: 'force pushes' disabled on branch 'main'","Warn: branch 'main' does not require approvers","Warn: codeowners review is not required on branch 'main'","Warn: no status checks found to merge onto branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T11:20:07.372Z","repository_id":38154662,"created_at":"2025-08-20T11:20:07.372Z","updated_at":"2025-08-20T11:20:07.372Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277378550,"owners_count":25808147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["indentation","python","typescript","visual-studio-code","vscode","vscode-extension"],"created_at":"2025-09-28T14:16:06.283Z","updated_at":"2025-09-28T14:16:10.427Z","avatar_url":"https://github.com/kbrose.png","language":"TypeScript","funding_links":["https://github.com/sponsors/kbrose","https://paypal.me/2kbrose"],"categories":[],"sub_categories":[],"readme":"# Python Indent\n\nCorrect Python indentation in Visual Studio Code. See the extension on the [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=KevinRose.vsc-python-indent\u0026ssr=true) and its source code on [GitHub](https://github.com/kbrose/vsc-python-indent).\n\n![](static/demo.gif)\n\n[![Build Status](https://github.com/kbrose/vsc-python-indent/actions/workflows/ci.yml/badge.svg)](https://github.com/kbrose/vsc-python-indent/actions?query=branch%3Amain)\n[![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/KevinRose.vsc-python-indent)](https://marketplace.visualstudio.com/items?itemName=KevinRose.vsc-python-indent)\n\n## How it works\n\nWhen you press `Enter`, your Python code is parsed up to the cursor in order to find the correct indentation level of nearby lines. Because the \"correct\" indentation level can be an arbitrary number of spaces, the use of tabs (`\\t`) is not supported.\n\nFor more detailed explanation of the behavior, see the section \"Detailed Behavior\" below.\n\n## Settings\n\nThere are three exposed settings.\n\n* `pythonIndent.useTabOnHangingIndent`\n* `pythonIndent.useTabOnHangingIndent`\n    * boolean, the default is false\n    * If true, after creating a hanging indent (see [footnote 1 of PEP8](https://peps.python.org/pep-0008/#fn-hi) for a definition of a hanging indent), you can use the tab key to leave the indented section and go to the ending bracket.\n* `pythonIndent.trimLinesWithOnlyWhitespace`\n    * boolean, the default is false\n    * If true, trims lines that contain only whitespace after pressing Enter on them. This behavior is similar to VS Code's default.\n* `pythonIndent.keepHangingBracketOnLine`\n    * boolean, the default is false\n    * If true, when creating a hanging indent, do not put the closing bracket on its own line.\n\n## Release notes\n\nSee the [change log](/CHANGELOG.md).\n\n## Detailed behavior\n\nThere are three main cases when determining the correct indentation, described below.\n\n### Between bracket pairs\n\nIn cases when you have your cursor between an open bracket (one of `[({`) and its closing bracket pair (the corresponding one of `})]`), this extension will keep subsequent lines indented just to the right of where it was opened:\n\n```python\ndata = {'a': 0,\n        | # \u003c- pressing enter should put your cursor at the \"|\"\n| # \u003c- this is where default VS Code puts your cursor\n```\n\nEven heavily nested brackets are handled:\n\n```python\ndata = {'a': 0,\n        'b': [[1, 2],\n              | # \u003c- match the more recently opened [ instead of the {\n        | # \u003c- default behavior of VS Code\n```\n\n```python\ndata = {'a': 0,\n        'b': [[1, 2],\n              [3, 4]],\n        | # \u003c- since the lists are all closed, go back to the { position\n              | # \u003c- default behavior of VS Code\n```\n\n```python\ndata = {'a': 0,\n        'b': [[1, 2],\n              [3, 4]],\n        'c': 5}\n| # \u003c- go back to indentation level before any brackets were opened\n        | # \u003c- default behavior of VS Code\n```\n\nIn the full example below, default VS Code required nine extra key presses (three tabs, two spaces, and four backspaces) to match the *automatic* indentation of this extension.\n\n```python\ndata = {'a': 0,\n        'b': [[1, 2],\n              [3, 4]],\n        'c': 5}\ndone(data)\n```\n\n### Hanging indents\n\nWhen you have opened a bracket, but not yet inserted any content, pressing `Enter` will create a hanging indent, matching the base behavior of VS Code.\n\n```python\nresult = my_func(\n    | # \u003c- your cursor should end up here\n) # \u003c- the closing bracket should end up here\n```\n\nYou can use the setting `useTabOnHangingIndent` to make it so that when you are done typing you can simply press `Tab` to be taken to the closing bracket.\n\nIf there is content to the right of your cursor when you press `Enter`, then this extension falls back on just indenting by your set tab size.\n\n```python\n# The \"|\" is your cursor's location\nresult = my_func(|x, y, z)\n# and when you press Enter...\nresult = my_func(\n    |x, y, z)\n```\n\nIf you never want to have the closing bracket end up on its own line (i.e. you always want to just indent by the set tab size), use the `keepHangingBracketOnLine` configuration setting. *Warning:* This may cause confusing indentation with function definitions as the argument list and the function code may end up at the same indentation level.\n\nIt's not often used, but a backslash to continue a line will also result in the next line being indented.\n\n```python\nmy_long_calculation = 1234 + \\\n    5678\n```\n\n### Keywords\n\nSome keywords in Python imply certain indentation behaviors. For example, if there is a `return` statement, then we know the next line can be un-indented (or *de*dented) since no statements can follow a `return` in the same code block. Other keywords that follow the same pattern are `pass`, `break`, `continue`, and `raise`.\n\nSimilarly, if there is an `else:` on the current line, then the current line needs to be dedented, and the next line needs to be indented *relative to* the new position of the `else:`. Other keywords that follow the same pattern are `elif ...:`, `except ...:`, and `finally:`. Some examples are shown below.\n\n```python\nif True:\n    pass\n    else:|\n# and when you press Enter...\nif True:\n    pass\nelse:\n    |\n```\n\nBut if you have manually changed the indentation, the extension should not change it for you:\n\n```python\nif True:\n    if True:\n        pass\n    else:|\n# and when you press Enter, do NOT dedent!\nif True:\n    if True:\n        pass\n    else:\n        |\n\n# Or even more nested\nif True:\n    if True:\n        if True:\n            pass\n    else:|\n# and when you press Enter, still do NOT dedent\nif True:\n    if True:\n        if True:\n            pass\n    else:\n        |\n```\n\n### Extending comments\n\nIf (and only if) you press `Enter` while your cursor is in the middle of a comment, then the next line will automatically be made into a comment.\n\n```python\n# As always, the \"|\" indicates your cursor\ndef f():\n    # This function is |gonna be REAL good!\n\ndef f():\n    # This function is\n    # |gonna be REAL good\n```\n\n### Trimming whitespace lines\n\nYou can trim whitespace from lines that contain *only* whitespace by using the `trimLinesWithOnlyWhitespace` configuration setting (the default is to not trim whitespace in this way). This setting brings the behavior closer to native VSCode behavior.\n\n```python\n# In the below code, the character \"·\" represents a space\ndef f():\n····|\n\n# The default of false preserves whitespace\ndef f():\n····\n····|\n\n# Setting trimLinesWithOnlyWhitespace = true will trim the whitespace\ndef f():\n\n····|\n```\n\n## Developing\n\nSee the [developer docs](/DEVELOP.md) for pointers on how to develop this extension.\n\n## Why is it needed?\n\nThis style of indentation has not been prioritized for support by the vscode-python team, and it's unclear if it ever will be.\n\nSee some related issues: [[1]](https://github.com/Microsoft/vscode-python/issues/481), [[2]](https://github.com/Microsoft/python-language-server/issues/671), [[3]](https://github.com/Microsoft/vscode/issues/66235), [[4]](https://github.com/Microsoft/vscode-python/issues/684), [[5]](https://github.com/Microsoft/vscode-python/issues/539)\n\n## Caveats\n\nKnown caveats are listed below.\n\n* Using tabs (`\\t`) for your indentation will not work.\n* If your Python code is not correctly formatted, you may not get correct indentation.\n* The extension works by registering the `Enter` key as a keyboard shortcut. The conditions when the shortcut is triggered have been heavily restricted, but there may still be times this extension is unexpectedly overriding `Enter` behavior. Specifically, `vim` related plugins seem to require special attention. See the [`when`](https://code.visualstudio.com/api/references/when-clause-contexts) clause in [package.json](./package.json).\n\nIf you experience any problems, please submit an [issue](https://github.com/kbrose/vsc-python-indent/issues), or a [pull request](https://github.com/kbrose/vsc-python-indent/pulls).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbrose%2Fvsc-python-indent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkbrose%2Fvsc-python-indent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbrose%2Fvsc-python-indent/lists"}