如何用空格或缩进注释多行 [英] How to comment multiple lines with space or indent

查看:119
本文介绍了如何用空格或缩进注释多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2010中,我要注释多行文本:

  A 
B
C

使用 CTRL + E + C 注释掉多行,我得到

  // A 
// B
// C

我想在 // A ,因此 // A 而不是 // A



但是,在将标签分组并缩进一行后, CTRL + E + C 不再注释掉所选文本。



如何对评论进行分组并获得以下内容:

  // A 
// B
// C


解决方案

一种方法是:


  1. 选择文本,按 CTRL + K C 进行评论( CTRL + E + C
  2. b $ b
  3. 将光标移到定界符 // 之后和代码文本之前的第一行。

  4. Alt + Shift 并使用箭头键进行选择。 (记住选择行(使用向下,向上箭头键),而不是文本选择-请参见。


    在注释定界符(//)和注释
    文本之间插入一个空格


    但是在Visual Studio中,注释的默认实现不会插入任何空格


    In Visual Studio 2010, I have multiple lines of text to be commented:

    A
    B
    C
    

    Using CTRL+E+C to comment out multiple lines, I get

    //A
    //B
    //C
    

    I would like to have a space (or indent) between // and A, hence // A instead of //A.

    However, after I group tab a block of text and indent it, CTRL+E+C no longer comments out the selected text.

    How to group comment and get the following:

    // A
    // B
    // C
    

    解决方案

    One way to do it would be:

    1. Select the text, Press CTRL + K, C to comment (CTRL+E+C )
    2. Move the cursor to the first line after the delimiter // and before the Code text.
    3. Press Alt + Shift and use arrow keys to make selection. (Remember to make line selection(using down, up arrow keys), not the text selection - See Box Selection and Multi line editing)
    4. Once the selection is done, press space bar to enter a single space.

    Notice the vertical blue line in the below image( that will appear once the selection is made, then you can insert any number of characters in between them)

    I couldn't find a direct way to do that. The interesting thing is that it is mentioned in the C# Coding Conventions (C# Programming Guide) under Commenting Conventions.

    Insert one space between the comment delimiter (//) and the comment text

    But the default implementation of commenting in visual studio doesn't insert any space

    这篇关于如何用空格或缩进注释多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆