Sublime Forum

Toggle Comment not working - menu or shortcut


I am trying out Sublime Text 2 on a Mac running Yosemite working on an actionscript file.

Neither the keyboard shortcut for toggle comment (Command-/) works nor does the Toggle Comment action from the menu.

I tried deleting the data folder from Application Support and hasn’t made a difference.
I can comment manully with //…
Any clues appreciated . ST2 looks amazing but not going to e for me if major bits dont work on my machine…

Tommy Banana



Tried ST2 & St3. Same problem.



Try enabling commands’ logging in the console to see if some package is stealing the shourtcut.
Open ST console and type


then try again to run the comment shortcut and see what the output is.

Anyway, on my machine (Win* w/ Qwerty it-IT keyboard) I had to change the keybindings from Ctrl+/ to Ctrl+7 (and Ctrl+shift+/ to Ctrl+shift+7) to make it works.

hope it helps



thing is it isnt just the shortcut. Menu based toggle commands not working either…



Try entering “sublime.log_commands(True)” in the console anyway, as Orlmente mentioned - you should see the following command in ST2 for Toggle Comment from both the menu and the shortcut:

command: toggle_comment {"block": false}


Yes I get:

command: toggle_comment {“block”: false}

but the selected code isn’t commented out.

I have had to make a macro in an external macro program to do it but it seems dumb.



IS there any other route to getting tech support for sublime text 2?
For paid software the fact that this basic functionality doesn’t work and noone is able to help is disappointing.

best tommybanana



I frequently write ActionScript in ST2 and Toggle Comment works fine for me, so I thought this was either a Yosemite bug or an isolated issue. But I just tested in a fresh install of ST3 on XP, and lo and behold, I get the exact behaviour you describe. Digging around in my ST2 customisations (and memory), I now recall that ActionScript comments have always been broken. Sorry, apparently I fixed this long ago on my machine but had forgotten that.

Anyway here’s a fix. Paste the following into a “Comments.tmPreferences” file and place it in a “/Data/Packages/User/ActionScript” directory.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

On my XP system this works for both ST2 and 3. I’ve generated a new UUID key for you in the above code, but you can create your own at this site, if you prefer:

Hope that fixes it for you!



Many thanks for the reply.

In Application Support/Sublime Text 2/Packages/

I have an ActionScript folder containing a file called ActionScript.tmLanguage which contains very similar code to what you supplied.

DO I just add it on the end of the file or should the code you sent replace code in there or should Imake a separate file and put it in thee.

Also I am not sure what the UUID stuff is about - is that about tracking changes?

NB There is a fairly low knowledge base operating at this end…


Tommy B.



Dont worry. I created a Comment.tmPreferences file and put into that folder and restarted and it is now working. Many thanks.



Glad to hear you got it working!

The “Comments.tmPreferences” file can indeed be placed in the “/Application Support/Sublime Text 2/Packages/ActionScript/” directory, as you did. But note that, in general, it’s better to confine ST customisations to the “/Packages/User/” directory, whenever possible. That way your changes will not get clobbered by ST updates, and they will be easier to back up or transfer to another machine. If you want to do that for this fix, create a “/Packages/User/ActionScript/” directory and move the “Comments.tmPreferences” file there.

UUID stands for “Universally Unique IDentifier”, and I suppose ST uses them to differentiate between the package files for the various language syntaxes, etc. If you’re curious about GUIDs and UUIDs then you can read about them here:

“GUID Guide” … t-one.aspx … t-two.aspx … three.aspx

By the way, if this fix wasn’t available then you could also have created a comments macro using ST (see the Tools menu), instead of using an external macro program.



I’m experiencing similar problem with ST3, except for toggle comments work from the menu, but it won’t obey to ANY key binding (!). Standard binding CMD+/ causes “command: copy” (as can be seen in console and clipboard :wink:, whenever I try to change binding, CMD+/ stays for copy command, but new binding won’t even work (yet in the menu it always shows CMD+/ as toggle comment shortcut!)
At the same time, toggling block comment works fine with any binding.
I tried disabling all packages (renamed Packages dir), searching for key conflicts (none that are related to CMD+/), updated to latest dev version… nothing helps.

Here’s my key binding lines:
{ “keys”: “super+shift+forward_slash”], “command”: “toggle_comment”, “args”: { “block”: true } },
{ “keys”: “super+forward_slash”], “command”: “toggle_comment”, “args”: { “block”: false } },

Any idea where else to dig?



kay, created a simple macro and could bind it to ctrl+/ (cmd+/ still wwon’t do anything apart from copying!)
{ “keys”: “ctrl+forward_slash”], “command”: “run_macro_file”, “args”: {“file”: “res://Packages/User/toggle_comment.sublime-macro”} },



Just for anyone getting here ( including me) . This works brilliantly for ST3 as well. Just make sure it saves as Comments.tmPreferences not Comments.tmPreferences.xml . Then restart ST3 and bob’s your uncle.

After 4 weeks the Actionscript directory in User just disappeared and I had to create it again. No idea what that happened but hey.