Skip to content

Strings with multiple whitespaces are formatted with single one #1026

Closed

Description

@luca-domenichini

Formatting this XML:

<Tag><Inner>Test     Spaces</Inner></Tag>

leads to this:

<Tag>
    <Inner>Test Spaces</Inner>
</Tag>

I am aware of #1017, and setting "files.trimTrailingWhitespace":false does not solve the problem. All multiple whitespaces are always formatted as single whitespce:

<Tag><Inner>   Test     Spaces   </Inner></Tag>

becomes:

<Tag>
    <Inner> Test Spaces </Inner>
</Tag>

Activity

  1. luca-domenichini commented on Sep 27, 2024

    @luca-domenichini
    Author

    Ok, I see that there is an option where you can specify tag names for which to preserve spaces.
    Adding tag <Inner> in my case, does fix the problem.
    image

    I think that manually adding tag names to a list is not an viable and scalable way to handle that.
    Probably, it would be better to add an option checkbox that sets the default handling for multiple whitespaces: when checked, it should preveserve whitespaces for all tags. And the tagnames list, maybe, should be turned in a blacklist for tags that need whitespaces trimmed.

    Also, using the legacy formatter preserves spaces as well.

  2. self-assigned this
    on Oct 3, 2026
  3. added this to the 0.30.0 milestone on Oct 3, 2026
  4. angelozerr commented on Oct 3, 2026

    @angelozerr
    Contributor
  5. 26 remaining items

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions