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条回答
Deceive 欺骗
2楼-- · 2019-01-12 16:34

Seems like some kind of keyboard mapping bug. I'm Portuguese, so I'm using a PT/PT keyboard. Sublime Text 3 apparently is handling / as ~.

查看更多
疯言疯语
3楼-- · 2019-01-12 16:35

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 } }
]
查看更多
成全新的幸福
4楼-- · 2019-01-12 16:39

Ctrl+d and Ctrl+Shift+d....

[

{ "keys": ["ctrl+d"], "command": "toggle_comment", "args": { "block": false } },

{ "keys": ["ctrl+shift+d"], "command": "toggle_comment", "args": { "block": true } },

]
查看更多
对你真心纯属浪费
5楼-- · 2019-01-12 16:41

Max OS: If you want to toggle comment multiple individual lines versus block comment an entire selection, you can do multi line edit, shift+cmd+L, then cmd+/ in that sequence.

查看更多
男人必须洒脱
6楼-- · 2019-01-12 16:45

On a Mac with a US keyboard, you want cmd+/.

查看更多
等我变得足够好
7楼-- · 2019-01-12 16:47

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 !

查看更多
登录 后发表回答