How to Comment Code in Visual Studio Code? Shortcut

Visual Studio Code has the possibility to comment and uncomment the single line code and multiple lines. I want to share two shortcuts to do it in the Windows OS. Both hotkeys work for single and multiple lines.

 CTRL  +  /  HotKey to Comment and Uncomment Lines

An example in the HTML(Angular project) file(line 355):
single line comment vs code

An example in the ts(Angular Typescript) file(line 31):
comment uncomment single line

 Shift  +  Alt  +  A  Longer HotKey to Comment and Uncomment Lines

An example in the HTML(Angular project) file:
shift-alt-a vs code
In the Html file, it wraps lines by the <!– –>

An example in the ts(TypeScript Angular) file:
shift alt a VS code typescript
In the ts file, it wraps lines by the /* */

Note: if you press Shift + Alt + A or CTRL + / without lines selection VS Code will add an empty comment tag <!– –> or /* */depending on the file extension.

For MAC OS: Shift + Option + A

How to remap/change these shortcuts?

Windows: File > Preferences > Keyboard Shortcuts.

remap comment uncomment hotkeys vs code menu
Visual Studio Code Toggle block comment

VS Code version: 1.72.2

Leave a Comment