Keyboard shortcut to comment lines in Sublime Text 2

user1419762 picture user1419762 · Jul 22, 2012 · Viewed 253.4k times · Source

In Sublime Text 2, how do I enclose a selection in a comment?
Is there a keyboard shortcut for this action?

Answer

Andrew Barrett picture Andrew Barrett · Jul 22, 2012

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 } },