Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the automatic asterisk in Visual Studio when adding a multi-line comment in C#? [duplicate]

Possible Duplicate:
How do I stop visual studio from automatically inserting asterisk during a block comment?

When adding a multi-line comment in Visual Studio, it automatically places an asterisk (*) at the beginning of a new line (on enter) inside the comment block. I personally find this a nuisance. Does anyone know how to disable it? Thanks.

like image 242
Zoman Avatar asked Feb 21 '10 21:02

Zoman


People also ask

What is the shortcut to comment multiple lines in C#?

Another way to comment out one or more lines of code to select the lines and click on the Comment or UnComment button in the Text Editor toolbar. Shortcut: You can use Ctrl+K, Ctrl+C and Ctrl+K, Ctrl+U to Comment or Uncomment selected lines of text.

How do you comment out a chunk of text in Visual Studio?

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 I comment out in C# Visual Studio?

They shortcut to comment out a block of code is "Ctrl+K, C" or "Ctrl+E, C" (as a reminder, I'm using the default C# settings in Visual Studio). To comment out a selection, we first highlight the code: And then just press "Ctrl+K, C": That's it.


2 Answers

Found this answer for you online (see here):

This works with Visual Studio 2005 and 2008:

  1. in the IDE, go to Tools->Import and Export Settings; then Export selected environment settings; deselect everything except Options->Text Editor; save to a new file.

  2. Edit your exported settings file in some text editor. Search for the string "AutoComment". There's a PropertyValue tag with value 1, change it to 0, and save the file.

  3. in the IDE, import this new file using Tools->Import and Export Settings. It should stop formatting comments right away.

To be clear, I haven't tested it myself yet . . . please let us know if it works for you.

Update:

Another way, as posted in the previous question on this (linked by Rob van Groenewoud, above)

Tools > Options... > Text Editor > C# > Advanced > Uncheck "Generate XML Documentation comments for ///".

(Of course, in addition to getting rid of the automatic * in block comments, this will disable the autoformatting when you type "///", as it says.)

It sounds like the solution I gave above does the same thing, but by editing the settings file itself instead of using the menu options.

like image 165
Tim Goodman Avatar answered Oct 08 '22 03:10

Tim Goodman


I would have left this as a comment on John Saunders' answer, but alas, my rep is not high enough :)

Vertical Selections

If you'd rather not be editing settings files, or you want to keep the automatic xml comment generation on typing "///", you could use vertical highlighting to select all the asterices and hit delete. Visual Studio, like Microsoft Office, gives you the ability to select a "column" of text: just hold alt and click-drag your selection across several lines.

Cool!

It's possible you know this already, but it's still worth mentioning.

like image 45
Seb Charrot Avatar answered Oct 08 '22 03:10

Seb Charrot