Skip to content

[folding] Collapse ending brace to the same line #3352

Open

Description

@Tyriar

Consider a large JavaScript file

function a() {
  ...
}

function b() {
  ...
}

function c() {
  ...
}

and so on...

Collapsing all currently yields:

function a() { ...
}

function b() { ...
}

function c() { ...
}

and so on...

This would be more readable if the closing brace was on the same line:

function a() { ... }

function b() { ... }

function c() { ... }

and so on...

Here is how other prominent editors handle the above:

Atom

image

Brackets

image

Sublime Text 3

image


VS Code

image

Activity

  1. tht13 commented on Feb 24, 2016

    @tht13
    Contributor

    This would not work for languages which do not use punctuation to signify code blocks (i.e python)

    Code Folding at the moment uses indentation and so will close everything up to the next line on the same indentation level as the folding line. The implementation would have to change to fold the closing bracket as this would cause issues in some languages

  2. joaomoreno commented on Feb 24, 2016

    @joaomoreno
    Contributor

    👍

  3. joaomoreno commented on Feb 24, 2016

    @joaomoreno
    Contributor
  4. added
    feature-request
    editor-folding
    on Feb 24, 2016
  5. changed the title [-]Proposal: Code folding collapses ending brace to the same line[/-] [+][folding] Collapse ending brace to the same line[/+] on Feb 24, 2016
  6. pom421 commented on Jul 12, 2016

    @pom421

    👍
    I like the Atom's way. We save a line and the ending curly brace is not virtually on the same line than the beginning one (unlike Bracket).

  7. danjoa commented on Dec 23, 2016

    @danjoa

    👍 definitely, would help so much

  8. g5codyswartz commented on Feb 1, 2017

    @g5codyswartz

    I like how Jetbrains does theirs which matches "bracket"
    image

    I also love being able to fold not only from the first bracket but also the last bracket.

    They also have essentially peeking for brackets when they're not on screen so you can see what they belong to. I used to comment what ending brackets belonged to, then I stopped due to the IDE, now I'm feeling lost again w/o it.
    image

    I also really like how notepad++ puts the trailing line as mentioned in Alternative Designs #2

  9. Spown commented on Aug 28, 2017

    @Spown

    I'm for the current model, but since people still think there is something to be corrected I think a preference is in order, something like editor.foldingConsumeLastLine: bool

  10. renestalder commented on Nov 24, 2017

    @renestalder

    Also would prefer a way to make it one-line. I often use the folding in CSS and liked the way the Jetbrains IDEs put the collapsed selectors on one line.

  11. 92 remaining items

  12. ammarsani-my commented on Sep 20, 2025

    @ammarsani-my

    https://marketplace.visualstudio.com/items?itemName=AtroxEGO.better-folding-plus
    For JSON, this might help.

    But still, +1 for this feature to support natively in vscode.

  13. Vasdranna commented on Jan 30, 2026

    @Vasdranna

    Any updates on this?

    It would be great to have this feature, including displaying only the region descriptions (e.g. showing Macros instead of //#region Macros).

  14. jucdev commented on Feb 24, 2026

    @jucdev

    Happy 10th anniversary!

    Image

  15. n-gist commented on Feb 26, 2026

    @n-gist
    Contributor

    Martin Aeschlimann (@aeschli) what would be the correct solution? Most obvious is to have a setting for this. If yes, what setting scope it should be included in?

    a) As a common vscode setting, like editor.foldingIncludeClosingBracketsOrTags: true | false | 'auto' (where true/false is for User preference, and auto is default, meaning that extension decides (current behavior)), so that we could set it for all or selected languages, and then leverage support of it by updating language extensions

    b) Each language extension should have its own setting for this

    I would go for a), though it will result in a line of extensions which not yet support the feature, but there will be a toggle ready, so it would just need to be picked up by corresponding extensions. b) would be free from this, but it is not convenient to configure each language separately, searching for the specific setting name, which will obviously be named differently by extension developers

    I'd like to try implementing this for ts/js, json, css, html (something else, of built-in ones?)

  16. gixxy22 commented on Mar 24, 2026

    @gixxy22

    switched to vscode from jetbrains, and this is the only thing that I miss, it makes code look cluttered and takes up more vertical space.

  17. serhumanos commented on Jun 17, 2026

    @serhumanos

    the Better Folding extension is not working as spected anymore, so we are alone again

  18. deleted a comment from on Sep 1, 2026
  19. deleted a comment from on Sep 1, 2026
  20. deleted a comment from on Sep 1, 2026
  21. deleted a comment from on Sep 1, 2026
  22. n-gist commented on Nov 22, 2026

    @n-gist
    Contributor

    TypeScript 7 should eventually handle this in its language server—it'll include the closing bracket line in the fold as long as there's only whitespace after the bracket when using the lineOnly: true mode that VS Code uses for TS7.
    microsoft/TypeScript#64235 microsoft/TypeScript#65319

  23. web3d0 commented on Nov 23, 2026

    @web3d0
  24. n-gist commented on Nov 23, 2026

    @n-gist
    Contributor

    I think this would affect the visual layout too significantly—something most users wouldn't expect—so it’s unlikely the TypeScript team would consider adding it. It would require a separate configuration setting, and it would likely be difficult to convince the team that it’s truly necessary, especially since this is something we can already control ourselves by simply removing those blank lines from the code.

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

Metadata

Metadata

Labels

editor-foldingfeature-request

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions