Sublime Forum

Noob keybinding problem

#1

hi all,

i’m new to this software, and i think i’m falling in love with it, but…

i’ve been trying to customise my keybindings. unfortunately, it doesn’t seem to work.

i want to set ctrl+# to toggle block comments - i want to select a block (in a python script say), hit ctrl+# and have that block commented out.

as i’m using windows, i’ve modified my \Packages\User\Default (Windows).sublime-keymap file to be

{ "keys": "ctrl+#"], "command": "toggle_comment", "args": { "block": true } }
]

i then save that file, restart ST2, but the new keybinding doesn’t work as expected.

what am i doing wrong?

i’m using ST2 Build 2181, soda theme (don’t know if it’s relevant), windows 7 x64.

0 Likes

#2

Probably it’s a better idea to bind to ctrl+shift+3 (or whatever) ?

0 Likes

#3

You may be using the wrong key name. Try turning on input logging to see what the actual key name is:

Turn the key logging (to the console) on by typing this in the console window:

sublime.log_input(True)

…and off with:

sublime.log_input(False)

Otherwise. have a look at http://sublimetext.info/docs/en/reference/key_bindings.html, it might help…

0 Likes

#4

thanks for the speedy replies, both of you.

the whole point of customising is that you get to choose what you want! :wink: is there a particular reason that i can’t use ctrl+#?

@jbjornson -thanks for that! it seems that when i hit ctrl+# on my (UK) keyboard, ST2 receives ctrl+’

it now works!

why is my keyboard mapping ‘screwed’ like this? is there a setting i can change somewhere, in ST or windows?

0 Likes

#5

This has to do with UK & US keyboards. Your preference should be on set up at the level of your OS — it doesn’t really matter what picture is on what key. I have all my keyboards set up as US, because I’m used to it, even though my netbook has a UK keyboard. Sublime should follow whatever you set up [1].

Incidentally, on a US keyboard, to get # you press Shift+3 (hence the keybinding that @iamntz suggested). More: en.wikipedia.org/wiki/British_an … _keyboards

If you’ve set up your keyboard correctly at the OS level then something else is the matter.

[1] I’ve had some trouble with keybindings in Greek but that’s a whole different alphabet :smile:

0 Likes