question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
DwightGappacommented, Mar 21, 2018

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

1reaction
call0fcodecommented, Aug 27, 2019

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 =(

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop Eclipse from mangling my comments - Stack Overflow
Go to Preferences -> Java -> Code Style -> Formatter · There edit the profile and switch to the last tab called "Comments"...
Read more >
Stop Visual Studio text editor from auto moving comment lines
In theses case CTRL-Z (undo) put the comments in the position they had before the alignment. To undo the user action another CTRL-Z...
Read more >
How about newlines within comments? - Meta Stack Exchange
Save this question. Show activity on this post. I am aware that comments have only a simple field, with no formatting possible and...
Read more >
Insert, delete, or change a comment - Microsoft Support
Insert a comment. Select the text you want to comment on, or click at the end of the text. On the Review tab,...
Read more >
comment indentation can break code indentation
I have the “Indent but do not format” on paste option enabled, ... of Visual Studio to report a new issue using Help->Send...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found