Reputation: 6763
I know there is keyboard shortcut for single line(//....) commenting Ctrl + K + C and uncommenting Ctrl + K + U .
My question is that, is there any default keyboard shortcut for block (/* ...... */) commenting and uncommenting? If yes how?
And If there is no default block commenting keyboard shortcut defined, So is there a way i could add my own keyboard shortcut for this? How do i do that?
I have found lot of questions regarding commenting, but haven't found spoken about block commenting anywhere. Any help is appreciated :)
Upvotes: 14
Views: 35665
Reputation: 17915
In latest version of Visual Studio Code (Version : 1.29.1(user setup)), you can try Ctrl+/
for single line comment & Shift+Alt+A
for block comment. If you can click on edit of your menu bar, there you should be able to find the necessary info.
Upvotes: 0
Reputation: 51
You can use three /// to create...
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Upvotes: 5
Reputation: 6666
for me, in Visual Studio 2015 community edition, when I select full lines it will insert //
comments. If I select the lines only partially (the first line is not selected from the very beginning or the last line is not selected till the end), it will insert /*
comments. The shortcut is the same, Ctrl + K + C
.
Full lines selected:
These lines will
be commented with //
Press Ctrl + K + C
Result:
//These lines will
//be commented with //
Partial lines selected:
These lines will
be commented
with /*
Press Ctrl + K + C
Result:
These /*lines will
be commented*/
with /*
Upvotes: 11
Reputation: 966
If you have resharper, you can use keyboard shortcut
Ctrl+Shift+/
to put block comment around selected statements. I hope this helps.
Upvotes: 6
Reputation: 27880
For a simple block comment you can create the following C# command in Visual Commander and assign a shortcut to it:
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
EnvDTE.TextSelection ts = DTE.ActiveDocument.Selection as EnvDTE.TextSelection;
ts.Text = "/* " + ts.Text + " */";
}
Upvotes: 2
Reputation: 11311
I used FeinCtrl to list all available commands, and there are only two related to commenting code in/out: Edit.CommentSelection and Edit.UncommentSelection; there are no other commands that could do a block commenting.
You can add your own shortcuts to any EXISTING command by going into Tools -> Options -> Environment -> Keyboard, selecting a command and assigning your new key combination.
If you search this site, you'll find a lot of reasons to NOT use block comments at all.
Upvotes: 7