Visual Studio /**/ comment shortcut?

C#C++Visual StudioKeyboard ShortcutsComments

C# Problem Overview


I want to know how to put the /**/ comments through shortcut. I know the Ctrl+K+C shortcut for the // comments but it comments the whole line. Sometimes while debugging, I want to do something like "ref string /* char[] */ lengthValue" while trying something out.

I want to be able to comment a specific part of a line (not the whole line) through a shortcut e.g in "string /* char[] */ lengthValue" i-e comment out only a specific part of a like by shortcut

I am using Visual Studio 2013

Please help

C# Solutions


Solution 1 - C#

Visual studio comment shortcut key: Accept in HTML, C#, JS, CSS etc in Visual studio.

Ctrl + k then Ctrl + c

//a
//b                      
//c

to undo ctrl + k then Ctrl + u

a
b
c

Ctrl + Shift + /

/*a
b
c*/

to undo Ctrl + Shift + /

a
b
c

Solution 2 - C#

I think there is no shortcut key for this purpose in Visual Studio but If you use ReSharper you can use Ctrl + Shift + /.

Have a look at this may be useful as well.

Solution 3 - C#

In Visual Studio 2017 RC, simply Select the part of code you want and then press Ctrl + K + C , no need to any extension!

Solution 4 - C#

VS 2019 I did

Tools > Options > Environment > Keyboard

Type in Edit.ToggleBlockComment and add a keybinding. I chose shft + ctrl + /

Or you could put comment in the search box of the keyboard section and look at all your comment keybinding shortcut options.

Solution 5 - C#

To comment a block of code (more than one line) in VS select code with ALT (alt+mouse or alt+shift+arrows), and then comment with Ctrl+K Ctrl+C. With one line code only you don't need ALT.

So it's basically the same as with // comments, only ALT needs to be pressed while selecting code for more lines than one.

Solution 6 - C#

In Visual Studio Code that is called Toggle Block Comments

By default command is Shift + Alt + A

But you can customize as your own in Visual Studio Code. I did it ctrl + shift + /

Hope it might help

Solution 7 - C#

Shift + Option + A - figured it out by going to Preferences > Keyboard Shortcuts and searching "comment"

Solution 8 - C#

You can now use Ctrl + Shift + A /* for block comments */

And Ctrl + ù // for line comments

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionZia KhattakView Question on Stackoverflow
Solution 1 - C#SuzaView Answer on Stackoverflow
Solution 2 - C#Salah AkbariView Answer on Stackoverflow
Solution 3 - C#Ali RashediView Answer on Stackoverflow
Solution 4 - C#mjwrazorView Answer on Stackoverflow
Solution 5 - C#czubajkaKaniaView Answer on Stackoverflow
Solution 6 - C#MuktaView Answer on Stackoverflow
Solution 7 - C#Max HudsonView Answer on Stackoverflow
Solution 8 - C#sdsdsdsdView Answer on Stackoverflow