In Visual Studio, I selected the lines and click "Comment out the selected lines" in the tool bar. The VS will put //
in front of all selected lines. How do I change the style so that the VS put the selected lines in between /**/
?
Asked
Active
Viewed 229 times
0
-
4I am _guessing_ that Visual Studio uses C++ style comments with that feature because C style comments can not be nested. If there's a `*/` anywhere in the code you have selected - even in a string or comment - your code will break if it's wrapped in `/**/`. – Drew Dormann Mar 15 '22 at 23:19
-
3I tend to do `#if 0 ... lines-want-to-comment-out ... #endif`. It's quick, easy and robust. Or sometimes I do `#ifdef COME_BACK_TO_THIS_LATER ... #endif`, depending. – Paul Sanders Mar 15 '22 at 23:24
-
2I haven't found an option to control this anywhere in Tools > Options. But you can get block comment behavior if either the first/last character of the selection is not at the beginning or end of a line. Also, consider learning the keyboard shortcuts: Ctrl-K+C to comment / Ctrl-K+U to uncomment. Oh, and I second the above -- use preprocessor to exclude blocks of code, as it supports nesting and you can use nice labels. There's nothing worse than coming across swathes of code in your repository that's just commented-out, or worse that parts of it have been double-commented-out. – paddy Mar 15 '22 at 23:24
1 Answers
0
Currently, there is no such setting you want in C++ project. You can go to Developer Community to propose this new feature and post the link in comment. In addition, Visual Studio now supports Ctrl + Shift + /
to comment and uncomment.

Minxin Yu - MSFT
- 2,234
- 1
- 3
- 14
-
Hi, @Taitai May I know if you have got any chance to check my answer? – Minxin Yu - MSFT Mar 17 '22 at 09:07