How to comment multiple lines in Visual Studio Code?

后端 未结 30 1863
感情败类
感情败类 2020-11-28 00:23

I cannot find a way to comment and uncomment multiple lines of code in Visual Studio Code.

Is it possible to comment and uncomment multiple lines in Visual Studio Co

相关标签:
30条回答
  • 2020-11-28 01:08

    In MacOS comment out multi-lines in Visual Studio Code by keyboard shortcut:

    Option + Shift + A

    /*
    ...
    ...
    */
    
    0 讨论(0)
  • 2020-11-28 01:08

    CTRL + / comment / uncomment multiple lines of code

    Ctrl+k+u for upper case latter

    ctrl+k+l for lower case latter

    0 讨论(0)
  • 2020-11-28 01:09
    1. Select all line you want comments

    2. CTRL + /

    0 讨论(0)
  • 2020-11-28 01:10

    To comment multiple line on visual code use

    shift+alt+a

    To comment single line use

    ctrl + /

    0 讨论(0)
  • 2020-11-28 01:11

    How to comment out multiline / single line in VS Code:


    MacOS:

    Shift + Option + A:

    /* multiline    
       comment */
    

    CMD + /:

    // single line comment    
    

    Windows:

    Shift + Alt + A:

     /* multiline
        comment */
    

    CTRL + /:

    // single line comment
    

    How to remap / change these shortcuts?

    Windows: File > Preferences > Keyboard Shortcuts.

    MacOS: Code > Preferences > Keyboard Shortcuts.

    You can search through the list both by keybindings (key names) and command names.


    Read: How to set shortcuts from another text editor (Sublime, Atom etc)?

    Official docs: Key Bindings for Visual Studio Code

    0 讨论(0)
  • 2020-11-28 01:12

    First, select the lines you want to comment/uncomment (CTRL+L is convenient to select a few lines)

    Then:

    • To toggle line comments, execute editor.action.commentLine (CTRL+/ on Windows)

      or

    • To add line comments, execute editor.action.addCommentLine (CTRL+K CTRL+C)

      To remove line comments, execute editor.action.removeCommentLine (CTRL+K CTRL+U)

      or

    • To toggle a block comment, execute editor.action.blockComment (SHIFT-ALT-A)

    See the official doc : Key Bindings for Visual Studio Code

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