How to comment a block in Eclipse?

前端 未结 17 2105
一整个雨季
一整个雨季 2020-12-07 08:52

Does Eclipse have a hot key to comment a block? and to uncomment a block?

相关标签:
17条回答
  • 2020-12-07 09:13

    There are two possibilities:

    Every line prepended with //

    ctrl + / to comment
    ctrl + \ to uncomment

    Note: on recent eclipse cdt, ctrl + / is used to toggle comments (and ctrl + \ has no more effect)

    Complete block surrounded with block comments /*

    ctrl + shift + / to comment
    ctrl + shift + \ to remove

    0 讨论(0)
  • 2020-12-07 09:16

    Using Eclipse Mars.1 CTRL + / on Linux in Java will comment out multiple lines of code. When trying to un-comment those multiple lines, Eclipse was commenting the comments. I found that if there is a blank line in the comments it will do this. If you have 10 lines of code, a blank line, and 10 more lines of code, CTRL + / will comment it all. You'll have to remove the line or un-comment them in blocks of 10.

    0 讨论(0)
  • 2020-12-07 09:19

    For single line comment you can use Ctrl+/ and for multiple line comment you can use Ctrl + Shift + / after selecting the lines you want to comment in java editor.

    On Mac/OS X you can use + / to comment out single lines or selected blocks.

    0 讨论(0)
  • 2020-12-07 09:19

    For JAVA :

    Single line comment:

                   // this is a single line comment
    

    To comment: Ctrl + Shift + C

    To uncomment: Press again Ctrl + Shift + C

    Multiple line comment:

             /* .........
                .........
                ......... */ 
    

    First, select all the lines that you want to comment/uncomment then,

    To comment: Ctrl + Shift + C

    To uncomment: Press again Ctrl + Shift + C

    I hope, this will work for you!

    0 讨论(0)
  • 2020-12-07 09:19

    Select the text you want to Block-comment/Block-uncomment.

    To comment, Ctrl + 6

    To uncomment, Ctrl + 8

    0 讨论(0)
  • 2020-12-07 09:20

    for java code

    if you want comments single line then put double forward slash before code of single line manually or by pressing Ctrl +/ example: //System.Out.println("HELLO");

    and for multi-line comments, Select code how much you want to comments and then press

    Shift+CTRL+/

    Now for XML code comments use Select code first and then press Shift+CTRL+/ for both single line and multi-line comments

    0 讨论(0)
提交回复
热议问题