Toggle Comment in VS Code (macOS)
Press Command + Slash to comment out the current line or the selected lines, or remove the comment.
What it does
Toggle Comment puts the line comment sign of the language in front of the current line, for example two slashes in JavaScript or a hash sign in Python. With several lines selected it comments all of them. Pressed on lines that are already commented, it removes the sign again. The editor takes the sign from the language of the file, so the same keys work in every language it knows.
The same shortcut on other platforms
| Platform | Shortcut |
|---|---|
| macOSthis page | Command + Slash |
| Windows | |
| Linux |
More VS Code shortcuts: General
- Find
- Find and Replace
- Go to Symbol
- Go to Line
- Go to Definition
All 71 VS Code shortcuts for macOSThe full list has a search and a printable PDF.
Questions
What is the VS Code shortcut for Toggle Comment on macOS?
⌘/ (Command + Slash). Press it to comment out the current line or the selected lines, or remove the comment.
What is the shortcut for Toggle Comment in VS Code on Windows and Linux?
On Windows it is Ctrl+/. On Linux it is Ctrl+/.