Skip to content
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

How may I tell the formatter, not to send my comments to a new line? #1337

Closed
pillaiindu opened this issue Feb 7, 2018 · 12 comments
Closed

Comments

@pillaiindu
Copy link

Originally requested VSCode to implement this feature.

I put comments on ending divs like the following

<div class="col">
  <div class="row">
    <div class="card">

      <h1>Some heading</h1>
      <p>Some text for the card.</p>
      <img src="some/image.jpg" alt="">

    </div> <!-- /.card -->
  </div> <!-- /.row -->
</div> <!-- /.col -->

I have also configured my emmet to put the closing div tag comments on the same line as the closing tag.

The problem:

When I format the document inside VSCode (my editor of choice) which uses js-beautify under the hood, it sends all of my closing div comments to the new line like the following,

<div class="col">
  <div class="row">
    <div class="card">

      <h1>Some heading</h1>
      <p>Some text for the card.</p>
      <img src="some/image.jpg" alt="">

    </div>
    <!-- /.card -->
  </div>
  <!-- /.row -->
</div>
<!-- /.col -->

Which is a problem for me, and I have to manually backspace them back to the closing div tags.
I requested VSCode team to provide a setting like "html.format.commentOnNewLine": true, which I set to false to get the desired effect, but they replied that they're using js-beautify under the hood which is doing the work, so I should file the feature here, which I did. :)

Thank You for the nice beautifier and the awesome work!

@DwightGappa
Copy link

I agree with pillaiindu. I have the same problem. I would like to see this implemented.

@bitwiseman
Copy link
Member

@gunther3613
Please review the CONTRIBUTING.md and submit a PR.

@peiris
Copy link

peiris commented May 3, 2018

Yes please add this feature. I have the exact same problem.

@pillaiindu
Copy link
Author

pillaiindu commented Jun 29, 2018

I unstared and stopped using js-beautify because of this issue.

@BrianLeishman
Copy link

@pillaiindu Same, I came from Netbeans, where the only formatting it did was (mainly) alter indentation, but it seems like this just tries to do too much, and altering my newlines is as annoying as it gets. It's too bad Netbeans just isn't as all around a good editor as VS Code, but since then I've just manually been formatting my code and I haven't looked back to either

@bitwiseman
Copy link
Member

#426

@bitwiseman
Copy link
Member

1.8.0-rc2.

@ghost ghost mentioned this issue Aug 17, 2018
@gkarapeev
Copy link

I still have the problem. I've been looking for a solution for two hours because it's driving me nuts, but still no luck. Below are my version specs.

version

@bitwiseman
Copy link
Member

@gkarapeev
Not sure why that would be. Please reproduce on beautifier.io and/or show examples of your inputs.

@call0fcode
Copy link

Using VSCode (1.37.1) with Beautify plugin installed (1.5.0) and set to default formatter on Linux it only works properly for me if I rewrite the comments next to the tag I want to have them.

If I open a file having previously written comments and try to format it, HTML one-line comments move to the next line which is absolutely undesirable and annoying cause it "breaks" my already formatted file =(

@bitwiseman
Copy link
Member

@gcjuan Please reproduce this on https://beautifier.io using the HTML beautifier. If it does happen there, please not the settings here.

@call0fcode
Copy link

@gcjuan Please reproduce this on https://beautifier.io using the HTML beautifier. If it does happen there, please not the settings here.

I cannot reproduce it on https://beautifier.io the way I do it in VSCode. It should mean there's a problem in the plugin implementation on the code editor cause it works time to time and depending if you've opened a file having already written comments or you write them afterwards.

Thanks for all!

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

No branches or pull requests

7 participants