简体   繁体   English

Visual Studio 2015中Visual c#块注释的键盘快捷键?

[英]Keyboard shortcut for Visual c# block comment in Visual Studio 2015?

I know there is keyboard shortcut for single line(//....) commenting Ctrl + K + C and uncommenting Ctrl + K + U . 我知道单行(// ....)注释Ctrl + K + C和取消注释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 :) 任何帮助表示赞赏:)

  1. I used FeinCtrl to list all available commands, and there are only two related to commenting code in/out: Edit.CommentSelection and Edit.UncommentSelection; 我使用FeinCtrl列出了所有可用的命令,只有两个与注释代码输入/输出有关:Edit.CommentSelection和Edit.UncommentSelection; there are no other commands that could do a block commenting. 没有其他命令可以执行块注释。

  2. 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. 通过进入工具->选项->环境->键盘,选择一个命令并分配新的组合键,可以将自己的快捷方式添加到任何现有命令中。

  3. If you search this site, you'll find a lot of reasons to NOT use block comments at all. 如果您搜索此站点,则会发现很多根本不使用块注释的原因。

for me, in Visual Studio 2015 community edition, when I select full lines it will insert // comments. 对我来说,在Visual Studio 2015社区版中,当我选择整行时,它将插入//注释。 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 . 快捷键是相同的, Ctrl + K + C

Full lines selected: 已选择整行:
These lines will be commented with //

Press Ctrl + K + C Ctrl + K + C

Result: 结果:

//These lines will //be commented with //

Partial lines selected: 选择的部分行:
These lines will be commented with /* 这些lines will be commented用/ * lines will be commented

Press Ctrl + K + C Ctrl + K + C

Result: 结果:

These /*lines will be commented*/ with /* 这些/*lines will be commented*/用/ * /*lines will be commented*/

If you have resharper, you can use keyboard shortcut 如果您有共享工具,可以使用键盘快捷键

Ctrl+Shift+/

to put block comment around selected statements. 在所选语句周围添加块注释。 I hope this helps. 我希望这有帮助。

You can use three /// to create... 您可以使用三个///创建...

/// <summary>
/// 
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

For a simple block comment you can create the following C# command in Visual Commander and assign a shortcut to it: 对于简单的块注释,可以在Visual Commander中创建以下C#命令并为其分配快捷方式:

public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
{
        EnvDTE.TextSelection ts = DTE.ActiveDocument.Selection as EnvDTE.TextSelection;
        ts.Text = "/* " + ts.Text + " */";
}

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. 在最新版本的Visual Studio Code(版本:1.29.1(用户设置))中,您可以尝试Ctrl+/用于单行注释,而Shift+Alt+A用于块注释。 If you can click on edit of your menu bar, there you should be able to find the necessary info. 如果您可以单击菜单栏的编辑 ,则应该可以在其中找到必要的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM