Skip to content

Auto-indent on closing brace #67678

Open
Open

Description

@alexagranov7

VSCode Version: Code 1.30.2
OS Version: Windows_NT x64 10.0.17763
Extensions: Extensions are enabled
image

on typing the closing brace. Meaning VSCode should take the current tab indentation size in account and auto-indent the code-block when typing the closing brace.

Activity

  1. vscodebot commented on Jan 31, 2019

    @vscodebot

    (Experimental duplicate detection)
    Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

  2. added
    editor-autoindent
    on Jan 31, 2019
  3. added
    feature-request
    on Feb 1, 2019
  4. Kenobi-the-2nd commented on Mar 6, 2020

    @Kenobi-the-2nd

    Yes, I would very much like to see this feature added as well. Oftentimes I will type in some code, then need to surround it in a loop, if statement, or other block contained by braces. When doing this, I expect that adding the closing brace after the initial brace will indent all code within the braces. I would expect the same behavior when surrounding code with other characters, such as brackets '[]', parentheses '()', or angled brackets '<>'.

    This is a standard feature that is present in other versions of Visual Studio such as Visual Studio Enterprise and even Visual Studio Community. When starting out using Visual Studio Code, I expected this same functionality and was disappointed to learn it was not present. This feature is a must-have and I sincerely hope that it will be added.

    Thank-you very much for your time.

  5. rudamaia commented on Apr 23, 2020

    @rudamaia

    visual studio for mac has this... Why it still not happening in vscode?

  6. vscode-triage-bot commented on Nov 3, 2020

    @vscode-triage-bot

    This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  7. vscode-triage-bot commented on Nov 21, 2020

    @vscode-triage-bot

    🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  8. GearTheWorld commented on Oct 22, 2021

    @GearTheWorld

    1.61.2 having Auto Indent to full and it doesn't work. Am I missing something?

    image

  9. gbirchmeier commented on Jan 5, 2023

    @gbirchmeier

    I don't understand why this is still an outstanding issue.

  10. dev-joss commented on Jan 12, 2023

    @dev-joss

    Adding my support to this, would love to see it implemented

  11. added
    javascript
    typescript
    on Mar 15, 2024
  12. aiday-mar commented on Mar 18, 2024

    @aiday-mar
    Collaborator

    Hi in order for us to better understand the issue, could you please include a screen recording of the issue you are seeing, as well as include a code sample where this is happening?

  13. gbirchmeier commented on Mar 18, 2024

    @gbirchmeier

    Aiday Marlen Kyzy (@aiday-mar) Here you go. It doesn't take much to replicate-- just create a new typescript file and write some code in it.

    My VSCode is 1.87.2, with plugin "JavaScript and TypeScript Nightly" v5.5.20240314.

    Screen.Recording.2024-03-18.at.11.57.39.AM.mov
  14. aiday-mar commented on Mar 28, 2024

    @aiday-mar
    Collaborator

    Hi I see thank you. As a temporary workaround, you may enable format on type or format on save from the settings:

    "editor.formatOnSave": true

    OR

    "editor.formatOnType": true

  15. bflora2 commented on Aug 1, 2024

    @bflora2

    I've been aggravated by this problem for a long time, but then I found a VSCode extension named "Universal Format on Type" by Crend King that seems to fix the problem perfectly. Woo-Hoo!

  16. chrisjaquet commented on Oct 12, 2024

    @chrisjaquet

    Enabling

    "editor.formatOnType": true
    

    does note trigger a reformat of the code block (or the line containing the closing brace). It only seems to adjust the indentation.

  17. lhmouse commented on Sep 3, 2025

    @lhmouse
  18. Brian-at-Baebies commented on Jan 13, 2026

    @Brian-at-Baebies

    Wow. Such a simple and longstanding feature of other MSFT IDEs and, five years after the request, it's still unimplemented. To summarize:

    • We want block contents to indent automatically when closing an enclosing set of braces added later
    • None of the Auto Indent settings do the right thing
    • Format on Type doesn't do the right thing
    • A third party extension seems to be a viable solution for some

    I've never developed an IDE before, so I don't know how hard it is to make this feature, but five years seems like enough time? Just how deep is the backlog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

editor-autoindentfeature-requestjavascripttree-sitter-autoindent-candidatetypescript

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions