Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard shortcut to comment lines in Sublime Text 2

Tags:

sublimetext2

People also ask

What is the shortcut for comment in Sublime Text?

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 + / .

What is the shortcut to comment all lines?

Press Ctrl + K .

Which shortcut key is used for comment?

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