Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop Visual Studio from automatically adding the end-of-comment characters when I start a new comment in a CSS file

In Visual Studio 2012, when I want to comment out one or more lines in a CSS file using the /* and */ characters, VS always automatically adds the closing comment characters */ right after I type the starting comment characters. So if I start with this block of code:

.appGrid {     display: -ms-grid;     -ms-grid-columns: 120px 1fr;     -ms-grid-rows: 140px 80px 1fr; } 

and I want to comment out the -ms-grid-rows line, I type /* at the beginning of that line. This is what I want to see:

.appGrid {     display: -ms-grid;     -ms-grid-columns: 120px 1fr; /*    -ms-grid-rows: 140px 80px 1fr; } 

Instead, VS adds the */ characters as soon as I finish typing the /* characters, like this:

.appGrid {     display: -ms-grid;     -ms-grid-columns: 120px 1fr; /**/    -ms-grid-rows: 140px 80px 1fr; } 

I then have to manually delete the automatically-added */ and re-add it where I actually want it...in this case at the end of the line I'm trying to comment out.

How can I stop VS from automatically adding the */ characters? I couldn't find any option to disable this behavior in Tools>Options>TextEditor>CSS.

For reference, I'm using VS2012 Premium.

like image 841
RSW Avatar asked Mar 13 '13 21:03

RSW


People also ask

How do you insert a comment in CSS stylesheet?

The /* */ comment syntax is used for both single and multiline comments. There is no other way to specify comments in external style sheets. However, when using the <style> element, you may use <!

How do you comment out code in Visual Studio code?

If you select a block of code and use the key sequence Ctrl+K+C, you'll comment out the section of code. Ctrl+K+U will uncomment the code.

How do you leave a comment in Visual Basic?

In VB . NET, you write a comment by writing an apostrophe ' or writing REM . This means the rest of the line will not be taken into account by the compiler.


2 Answers

I'm afraid there isn't an option to change this in Visual Studio, at least not one I can see. I've had the same issue sometimes, and generally use three ways around it:

  1. Select the lines to comment out and use the keyboard shortcut: CTRL+K, C
  2. Cut the closing */ and paste it at the end of the location
  3. Press CTRL+Z to undo the closing */

The first is the best method, but if I've already started typing 2 or 3 are enough to get through the break in flow!

like image 126
Rich Avatar answered Sep 21 '22 18:09

Rich


Visual Studio - Tools - Options - Text Editor - C/C++ - General - Uncheck 'Automatic brace completion'

like image 39
B H Avatar answered Sep 25 '22 18:09

B H