Toggle Comment in VS Code (Linux)
Press Ctrl + 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 |
|---|---|
| Linuxthis page | Ctrl + Slash |
| macOS | |
| Windows |
More VS Code shortcuts: Editing
- Outdent Line
- Indent Line
- Select Word / Next Occurrence
- Select All Occurrences
- Move Line Up
All 29 VS Code shortcuts for LinuxThe full list has a search and a printable PDF.
Questions
What is the VS Code shortcut for Toggle Comment on Linux?
Ctrl+/ (Ctrl + 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 macOS and Windows?
On macOS it is ⌘/. On Windows it is Ctrl+/.