Ahh, gotcha.
Possible reasons for the toggle comment command not doing what you want include Sublime not knowing how to comment the kind of file that you’re editing or, if you’re using a non-US keyboard layout, Sublime may not properly recognize the key that you’re pressing.
To double check, open up a file that you want to comment, position the cursor where you’d normally hit the key sequence, and then view the Sublime console by selecting View > Show Console
from the menu.
In the console, input the following commands:
sublime.log_commands(True)
sublime.log_input(True)
With that done, switch back to the file that you’re commenting on and press the keyboard shortcut for toggling a comment. You will see something similar to the following in the console (you may see other key events and commands displayed as well; that’s OK, just focus on the entries that appear when you take the action).
>>> sublime.log_commands(True)
>>> sublime.log_input(True)
key evt: control+/
command: toggle_comment {"block": false}
Command says toggle_comment
If you see the command toggle_comment
trigger as it did here, then Sublime knows you want to toggle a comment, but it can’t because it doesn’t know how to comment that particular kind of file. You will see this if you do this in a plain text file, for example.
If you see this, make sure that the bottom right of the status line agrees with what sort of file you think you’re editing. If it doesn’t, then you need to change the syntax of the file you’re using, change the extension to one that Sublime recognizes for that file, or possibly save your file if you just created it but haven’t saved it yet.
Key event doesn’t match the key you pressed
If you don’t see a key event that matches the key you pressed, then the problem is that your keyboard layout doesn’t match what Sublime is using, so it doesn’t think that you’re pressing the key to toggle a comment and thus doesn’t know what you’re asking.
In that case, aside of changing your keyboard layout the fix is to do something as outlined above and add a custom binding that maps the command to the key the way that Sublime sees it. You should do something similar to what I outlined above, but replace the key with what Sublime reports as the key evt
value.
No key event at all
It’s also possible that perhaps pressing the key doesn’t display any key evt
information at all. If that’s the case, then Sublime isn’t reacting because it doesn’t know you pressed a key at all.
The most likely culprit in this case is that the key is being “stolen” by some other application or the OS itself, which is seeing the input and grabbing it before Sublime gets to see it. This can also happen if the key you’re pressing is a “dead” key, such as one of the keys in a key sequence that you would use in a non-english language to add diacritical marks and accents to another character.
In this case your recourse is to remap the key; either in Sublime to be something different or at the point where it’s being stolen, depending on which is easier or possible (the OS may not let you change a global shortcut, for example).
In the case of it being a dead key you generally have to either change your keyboard layout entirely or remap the key in Sublime to some other key that’s not dead.