Sublime Forum

Shortcuts not working (Ctrl+U, Ctrl+/, etc.)

#1

Hi

I must say I am starting to like Sublime Text 2 as an editor, discovering more and more powerful functionality. However, I am having issues with keyboard shortcuts all the time. A lot of things seem to not work properly.

The two shortcuts that are currently not working are:

  • Ctrl+/ and Ctrl+Shift+/ to toggle comments (tried in HTML file, JS file) -> Nothing happens
  • Ctrl+u after doing a multi-selection and wanting to go back 1 (described here: sublimetext.com/docs/2/multi … board.html) --> the whole multi selection is canceled instead

I am using Swiss-German keyboard layout. Not sure if that has any effect. I had problems playing Starcraft 2 because the game confused z and y, but only sometimes. So for playing I had to switch to US english layout :unamused:

The configuration seems to be fine:
{ “keys”: “ctrl+/”], “command”: “toggle_comment”, “args”: { “block”: false } },
{ “keys”: “ctrl+shift+/”], “command”: “toggle_comment”, “args”: { “block”: true } },

{ “keys”: “ctrl+u”], “command”: “soft_undo” },

I am using Sublime Text 2, Build 2181 on Windows 8 Consumer Preview

0 Likes

Correct identify keyboard layout
"set mark" hotkey not working
Key input not handled correctly
#2

Run:sublime.log_input(True) sublime.log_commands(True)
in the Sublime Console and it’ll print out what keys it gets and the commands that it runs. This should aid you in debugging and changing the key bindings to something that works for you.

0 Likes

#3

Hello quarnster

Thank you, this brings me one step closer to finding and fixing the problems I had. I already figured out why Ctrl+Shift+N wasn’t opening a new window in html files --> Because it was conflicting with ZenCoding.

However, for the problems described in this thread I still haven’t found a fix:

**Ctrl+/ **

Turns out that Sublime doesn’t receive Ctrl+/, but instead key evt: control+keypad_divide. As I am using the / on the NumPad (haven’t got another). I have tried to add the following lines to the user keymap:

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

Unfortunately, this doesn’t trigger the command. The result in the console log is exactly the same. key evt: control+keypad_divide. No output for any command in sight.
Am I missing something? Of course I restarted Sublime before trying again.

Ctrl + U with multi selections

As far as this goes, the keystroke and the control seem to be triggered correctly:

key evt: control+u
command: soft_undo

Maybe it is by design that when hitting this soft undo with multi selections, that it cancels the whole multi selection. Pity realy, because Esc does the same.

Cheers

0 Likes

#4

Try ctrl instead of control

1 Like

#5

You nailed it! Thanks.

I think it’s time for me to start the weekend… :unamused:

0 Likes

#6

I just faced a similar issue, but I have a German keyboard, meaning the toggle shortcuts are ctrl+7 and ctrl+shift+7.
I tried leaving the defaults:

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

but it does not work, had to replace them all together with only one key:

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

Many other european keyboards use the same layout. Can’t sublime add these bindings out of the box?

I’m curious to how other applications handle these keyboard discrepancies.

0 Likes

#7

Similar problems with Spanish-Spain keyboard.
For example:
To get Ctrl+it's necessary to press Ctrl+Ñ. Ctrl+Shift+ is Ctrl+Shift+’
Ctrl+Shift+] is Ctrl+Shift+¡ Ctrl+Shift+; is Ctrl+Shift+

0 Likes

#8

Hello there,

just registered to share my knowledge: users who have a german keyboard and want to uncomment:

  • use “ctrl”+ “-” to uncomment the current line

  • use “ctrl” + “shift” + “-” to uncomment the currently selected text

I guess this is because an english keyboard has its slash ("/") next to the right shift key, where the german ones have the minus…?

Greets!

Edit:
Sorry, somehow i had a russian keyboard layout set (maybe some shortcut pressed mistakenly). So Ctrl± does not work in german keyboard layout. Nevermind.

0 Likes

#9

Hey guys,

most of you may figured it out already, but the Key Combo to toggle_comment is “ctrl+#” just hit it by accident, when trying the + and - combos described in the post above. :smiley:

Hope this helps.

Greets
Peter

@ just started using sublime to learn programming and i love it. I had to add this. :smile:

0 Likes

#10

I’m scratching my head trying to figure out why “CMD+/” and “CMD+ALT+/” for comments won’t work on my mac. I tried to type: sublime.log_input(True) sublime.log_commands(True) to have an understanding, but it looks like those combos are the only ones that won’t do nothing. They don’t even get logged.

These are my defaults: { "keys": "super+forward_slash"], "command": "toggle_comment", "args": { "block": false } }, { "keys": "super+alt+forward_slash"], "command": "toggle_comment", "args": { "block": true } }, Any suggestion, please?

I already tried reinstalling from scratch and getting rid of both packages and support files with Hazel. Both latest stable version (2217) and nightly (2219) won’t notice these key combinations.

0 Likes

#11

Hi guys. I’m dealing with the same issue. However, I just changed the shortcut from ctrl + / to ctrl + 7 and now it works fine. :smiley: You can change it here: Preferences --> Key Binding (default) --> Press Ctrl + F and search for comment. Once you find toggle_comment, change the shortcut to whatever you want it to be. :slight_smile:

Hope it helps!

/Dado

1 Like

#12

Only to complement the tip, to change the shurtcuts or any other setting, you need to go to Key Bindings - Default, find the setting to be changed and copy it to Key Bindings - User where you can change it to the new configuration. i.e. in order to change comment/uncomment code, search for comment in Key Bindings - Default and copy the both lines that referes to this topic. Then, paste them in Key Bindings - User, it must be inside both square parenthesis, and modify for the new config:
in Key Bindings - Default you’ll find:
{ “keys”: [“ctrl+/”], “command”: “toggle_comment”, “args”: { “block”: false } },
{ “keys”: [“ctrl+shift+/”], “command”: “toggle_comment”, “args”: { “block”: true } },
in Key Bindings - User you must paste and modify:
{ “keys”: [“ctrl+7”], “command”: “toggle_comment”, “args”: { “block”: false } },
{ “keys”: [“ctrl+shift+7”], “command”: “toggle_comment”, “args”: { “block”: true } },
don’t forget to end your lines with colon “,”

0 Likes

#13

Hi

I had the same issue for ages. never really cared about it but in past few days i really needed the comment key bind. So, I decided to search online and found this page. Replies really helped me but problem was still there. I did some stuff myself and discovered if you, change '/ ’ to ’ keypad_divide ’ , It starts working. I know this reply is late but i hope this help other people having the same problem.

Ahmad.

0 Likes

#14

Hello,

I’m in full misunderstanding what’s going with key-bindings on Windows 10. Shortcuts are working as expected for the first hit only, after does not work. For example ctrl+m for bracket pair moves pointer first time only, then adds a newline. Note, all of packages are disabled.

key evt: control+m
command: move_to {“to”: “brackets”}
key evt: enter
command: insert {“characters”: “\n”}

But after changing keyboard language settings to non-English then back to English, ctrl+m starts to work again, for the single action. And similarly with comments. - sometimes they working, sometimes not.

Does anyone can hint me how to solve this issue?

==

Update: it looks like this problem is not Sublime Text packages dependent.

After I disabled Lifehacker’s Texter application, Sublime’s shortcuts started to work as expected. Quite curious because Texter’s shortcuts are different from Sublime’s.

0 Likes