How to comment multiple lines in Visual Studio Code?

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


The keyboard shortcut to comment multiple in Windows is shift+alt+A.


Windows: Shift+Alt+A

Linux: Shift+Ctrl+A

Here you can find all the keyboard shortcuts:

Windows VSCode Shortcuts

Linux VSCode Shortcuts

PS: I prefer Ctrl+Shift+/ for toggling block comments because Ctrl+/ is shortcut for toggling line comments so it's naturally easier to remember. To do so, just click on the settings icon in the bottom left of the screen and click 'Keyboard Shortcuts' and find "toggle block...". Then click and enter your desired combination.


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