Search code examples
c++visual-studio

How to use single comment lines only in Visual Studio (C++)?


I am trying to do single-line comments in Visual Studio when selecting multiple lines, but can't seem to get it to work properly.

When I use Ctrl+/ or Ctrl+Shift+/ or Ctrl+K Ctrl+C, Visual Studio will ALWAYS use multi-line comments (which I hate), e.g. (result of Ctrl+K Ctrl+C)

transparent/*WindowShader.setMat4("model", model);
transparentWindowShader.setMat4("view", view);
transparentWindow*/Shader.setMat4("projection", projection);

Is there a way so it can simply comment like this instead?

// transparentWindowShader.setMat4("model", model);
// transparentWindowShader.setMat4("view", view);
// transparentWindowShader.setMat4("projection", projection);

The only way I have found to be working currently is to comment line by line, pressing the shortcut multiple times.

Also, is there a way to simply disable entirely the multi-line comments (which I don't want to use)?

I have tried everything I could find on the Internet to use single-line comments only in Visual Studio to no avail, so I'm hoping someone can help me because I can't believe something so simple and "standard" is not supported in VS.


Edit:

If I press Ctrk+/ twice, it will comment that way, but will still insert the annoying /* and */ that I need to remove manually.


Edit 2:

Running Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.12.4.


Edit 3:

Video showing the problem


Solution

  • You can combine shift + alt + e -> ctrl + /. Expand select to line -> comment.