To add single-line comments, put the text cursor on the line to comment-out or highlight multiple lines and type CMD + / on Mac, for Linux and Windows use CTRL + / .
Press Ctrl + K .
The Basics. The most basic shortcut for creating a comment is Ctrl+K, Ctrl+C.
By default on Linux/Windows for an English keyboard the shortcut is Ctrl+Shift+/ to toggle a block comment, and Ctrl+/ to toggle a line comment.
If you go into Preferences->Key Bindings - Default
, you can find all the shortcuts, below are the lines for commenting.
{ "keys": ["ctrl+/"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+/"], "command": "toggle_comment", "args": { "block": true } },
In the "Preferences->Key Bindings - User"
[
{ "keys": ["ctrl+7"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } }
]
Just paste it, these are will work great !
I'd like to add, that on my mac by default block comment toggle shortcut is cmd+alt+/
For German keyboards use ctrl+shift+# to toggle a block comment and ctrl+# to toggle a line comment.
The shortcut in Preferences->Key Bindings - Default
is set to Ctrl+Shift+/ and Ctrl+/, but to actually use the functions, press the keys stated above.
In a Brazilian Portuguese ABNT2 keyboard I have a similar issue to the one reported by JoshDM. In the file sublime-keymap I have:
{ "keys": ["ctrl+/"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+/"], "command": "toggle_comment", "args": { "block": true } },
But I have to use ctrl+; and ctrl+shift+;. On my keyboard, ; is on the left of /.
It seems like a bug.
you need to replace "/" with "7", it works on non english keyboard layout.
This did the trick for me coming from Brackets and being used to ctrl+/ on the numpad.
[
{ "keys": ["ctrl+keypad_divide"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+keypad_divide"], "command": "toggle_comment", "args": { "block": true } }
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With