Keyboard shortcut to comment lines in Sublime Text

2019-01-12 16:15发布

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

15条回答
姐就是有狂的资本
2楼-- · 2019-01-12 16:58

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 } },
查看更多
家丑人穷心不美
3楼-- · 2019-01-12 16:58

I'd like to add, that on my mac by default block comment toggle shortcut is cmd+alt+/

查看更多
仙女界的扛把子
4楼-- · 2019-01-12 16:59

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.

查看更多
登录 后发表回答