Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>One Line CommentsNew to Visual Studio Code? Get it now.
One Line Comments

One Line Comments

8rin5x

|
2,592 installs
| (4) | Free
html/css comment fix
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

One Line Comments

About

If your code contains a comment, and you want to add a new comment to temporarily disable a block or portion of code, the built in commenting functionality does not actually place the comment tags in expected locations. If an existing comment is included in the content being commented out, the first instance of a --> or */ closing comment tag will end the entire comment.

This extension will convert pre-existing comments to safe characters, allowing a new block comment that includes the original comment. It also reverses the effect to uncomment the same block of code.

Features

If you need to comment out a portion of your code that includes pre-existing comments, the native commenting functionality will not comment properly or preserve your existing comments. This extension will maintain your original comments and allow you to quickly toggle comments on sections of code.

Examples

HTML Syntax

HTML example

<main>
  <div class="container">
    <h2>Hello World</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
    <!-- <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit.</p> -->
  </div>
</main>

Becomes:

<!-- <main> -->
  <!-- <div class="container"> -->
    <!-- <h2>Hello World</h2> -->
    <!-- <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p> -->
    <!-- <!~~ <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit.</p> ~~> -->
  <!-- </div> -->
<!-- </main> -->

CSS Syntax

CSS example

.example {
  /* display: flex; */
  transition: all 0.5s;
  /* user-select: none; */
  background: linear-gradient(to bottom, white, black);
}

Becomes:

/* .example { */
  /* /~ display: flex; ~/ */
  /* transition: all 0.5s; */
  /* /~ user-select: none; ~/ */
  /* background: linear-gradient(to bottom, white, black); */
/* } */

Usage

Select the commented or uncommented line to execute the command.

Default Keybindings

  • Toggle comment/uncomment

    • Mac: cmd+/
    • Windows: ctrl+/
  • To comment

    • Mac: cmd+k cmd+c
    • Windows: ctrl+k ctrl+c
  • Uncomment

    • Mac: cmd+k cmd+u
    • Windows: ctrl+k ctrl+u

Configuration

  • oneLineComments.customCommentTags
    • You can add and edit comment tags
    • rule
      • Specify by language ID
      • Requires 4 items "outer_start", "outer_end", "inner_start", "inner_end"
      • Comment tags are only 1 to 5 character symbols

settings.json example

The following languages are supported by default:

  • html
  • css

Known Issues

None at this time

Release Notes

Full release notes are available in the CHANGELOG file.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft