26

I've edited the file Preferences > Key Bindings User, and added this:

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

But the shortcuts doesn't work. What went wrong?

Funny Frontend
  • 3,807
  • 11
  • 37
  • 56

10 Answers10

48

I solved my problem:

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

Just replace '/' by 'keypad_divide'

Funny Frontend
  • 3,807
  • 11
  • 37
  • 56
16

This works for me, with a QWERTY (Italian) keyboard, where the / is above the number 7.

Add in Preferences > Key Bindings User

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

It should works good on German QWERTZ keyboard also.

Community
  • 1
  • 1
Andrea
  • 15,900
  • 18
  • 65
  • 84
2

This worked for me on Windows 10:

{ "keys": ["control+keypad_divide"],"command": "toggle_comment", "args": {"block": false} }, 
{ "keys": ["shift+control+keypad_divide"],"command": "toggle_comment", "args": {"block": true}}
Alex
  • 503
  • 4
  • 7
1

I was having the same problem, but what worked for me was

ctrl + ç

without going to preferences.

(I have no idea why, notice is the c cedilla)

Rosa Alejandra
  • 732
  • 5
  • 21
1

With portuguese keyboard layout (my case) I had to use this:

{ "keys": ["ctrl+7"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } }
marcogmonteiro
  • 2,061
  • 1
  • 17
  • 26
1

The solution for italian keyboards also works for spanish keyboards on Windows 10:

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

Follows this link for the solution: Keyboard shorcut to Toggle (Block) comment in Sublime-Text

Few additional comments:

  1. Also, as a good practice try to edit the Default (Windows).sublime-keymap -User file to place your personal preferences
  2. If the symbol still doesn't works for you, possibly due to different keyboard layout, then can change opt for other key as well for e.g.

"keys": ["ctrl+shift+#"] ...

in the Default (Windows).sublime-keymap -User file.

Community
  • 1
  • 1
vsr
  • 1,025
  • 9
  • 17
0

This one work for me under window 10

{ "keys": ["ctrl+'"], "command": "toggle_comment", "args": { "block": false } },
{ "keys": ["ctrl+shift+'"], "command": "toggle_comment", "args": { "block": true } }
-2

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

keypad_divide just solve my problem

-2

This has solved the issue for me, without having to add an alternate keyboard shortcut:

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

I don't quite understand why. This key undoubtedly types a slash(/) but SublimeText interprets it as an apostrophe(') in the key binding.