Skip to content

Formatting JSON removes blank lines #37422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Nov 1, 2017 · 2 comments
Closed

Formatting JSON removes blank lines #37422

ghost opened this issue Nov 1, 2017 · 2 comments
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)

Comments

@ghost
Copy link

ghost commented Nov 1, 2017

  • VSCode Version: Code - Insiders 1.18.0-insider (8deed53, 2017-10-30T05:21:47.015Z)
  • OS Version: Windows_NT x64 10.0.15063
  • Extensions: none

Steps to Reproduce:

  1. Create a file foo.json containing:
{
    // part 1
    "x": 1,
    "y": 2,
    
    // part 2
    "a": 1,
    "b": 2
}
  1. Format Document
  2. The blank line is removed.

It would be nice if formatting JSON preserved blank lines (but still did things like inserting a space after a :).

@vscodebot vscodebot bot added insiders json JSON support issues labels Nov 1, 2017
@Spown
Copy link

Spown commented Nov 1, 2017

would be not. formatting generally means removing extraneous whitespaces and adding missing ones where they are expected. a blank line falls into the first category. I wouldn't mind having a user setting for this, but 👎 for making it a default behavior.

@octref octref added *question Issue represents a question, should be posted to StackOverflow (VS Code) and removed insiders json JSON support issues labels Nov 2, 2017
@octref
Copy link
Contributor

octref commented Nov 2, 2017

This is indeed the behavior of the built-in json formatter. You can install prettier https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode which preserves the whitespace in JSON.

@octref octref closed this as completed Nov 2, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code)
Projects
None yet
Development

No branches or pull requests

2 participants