Sublime Forum

Toggle Comment not working - menu or shortcut

#1

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…
best

Tommy Banana

0 Likes

#2

Tried ST2 & St3. Same problem.

0 Likes

#3

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

sublime.log_commands(True)

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
:smile:

0 Likes

#4

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

0 Likes

#5

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}
0 Likes

#6

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.

0 Likes

#7

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

0 Likes

#8

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" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>name</key>
	<string>Comments</string>
	<key>scope</key>
	<string>source.actionscript</string>
	<key>settings</key>
	<dict>
		<key>shellVariables</key>
		<array>
			<dict>
				<key>name</key>
				<string>TM_COMMENT_START</string>
				<key>value</key>
				<string>//</string>
			</dict>
			<dict>
				<key>name</key>
				<string>TM_COMMENT_START_2</string>
				<key>value</key>
				<string>/*</string>
			</dict>
			<dict>
				<key>name</key>
				<string>TM_COMMENT_END_2</string>
				<key>value</key>
				<string>*/</string>
			</dict>
		</array>
	</dict>
	<key>uuid</key>
	<string>6E85C1ED-6F2D-443B-B326-64947FE44621</string>
</dict>
</plist>

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:

famkruithof.net/uuid/uuidgen

Hope that fixes it for you!

0 Likes

#9

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…

Best

Tommy B.

0 Likes

#10

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

0 Likes

#11

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”
blogs.msdn.com/b/ericlippert/arc … t-one.aspx
blogs.msdn.com/b/ericlippert/arc … t-two.aspx
blogs.msdn.com/b/ericlippert/arc … 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.

0 Likes

#12

Hello,
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?

0 Likes

#13

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”} },

0 Likes

#14

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.

0 Likes