Sublime Forum

Issue with Key Binding

#1

Hi there,

I’m trying to bind " ctrl+shift+’ " on Windows (XP), but it doesn’t appear to be working, is there a known issue with using the single quote key, or does it relate to keyboard layouts?

Apologies if this has been answered elsewhere, I did have a quick search, but couldn’t see anything obvious!

Thanks in advance,

Dom

0 Likes

#2

Assuming that you use American keyboard layout, you could try if key-binding with double-quote character works. Ultimately, if you are holding shift, you trigger double quote, not single quote so it makes sense that your binding doesn’t work.

0 Likes

#3

ctrl+shift+’ is working for me (Windows 7). Specifically, this is the key binding file I tried:


	{ "keys": "ctrl+shift+'"], "command": "select_all" }
]

Keyboard layouts can prevent this from working, if they don’t specify any keys mapping to the virtual key code 0xDE. If you aren’t getting any luck with the above, try temporarily switching to a US keyboard layout and see if that’s working for you.

0 Likes

#4

Thanks both. I have tried using ctrl+shift+’, ctrl+shift+@ and ctrl+shift+" to no avail. Also, as to switching to US keyboard layout, sometimes Sublime seems to act like it’s using a US keyboard layout, and when it does, that ctrl+shift+’ key command works… I haven’t mentioned it as a bug, since it’s quite beneficial to me, but it certainly happens sometimes, when it does, quitting and restarting gets it back to standard (UK) layout but the shortcut stops working :frowning:.

If you’d like some more debug info on the keyboard layout, let me know (you may have to tell me how to get it ;P)

0 Likes

#5

The UK keyboard layout assigns the “’/@” key a virtual key code of 0xC0 (aka VK_OEM_3), which is used for the "/~" key on the US keyboard layout. Consequently, you can bind to it using the character. Sublime Text’s key binding system on windows is based around virtual key codes, rather than emitted characters. It means some issues such as this are unavoidable, but is overall a net win.

If your keyboard layout is changing for you at random, then it may be that you have a key sequence defined (in Region and Language settings in the control panel) that changes between them - IIRC this happens by default.

0 Likes

#6

There is a way of defining multiple keys based on scope type?
I mean if the file type is html, when i press ctrl+b the selection to be wrapped lie this

{ "keys": "ctrl+b"], "command": "insert_snippet", "args" : { "contents": "<strong>${1:$SELECTION}</strong>" } }
But if is … let’s say css, to insert font-weight:700

I tried to do like this:

"keys": "ctrl+b", "ctrl+g"], 

with no luck.

Also, i tried to add:

"scope":"html"

In (or out) args with no luck.

Make sense or i’m rambling? :smiley:

0 Likes

#7

Something like this ?

[code]
{ “keys”: “alt+o”], “command”: “switch_file”, “args”: {“extensions”: “pas”, “dfm”]}, “context”:

		{ "key": "selector", "operator": "equal", "operand": "source.pascal" }
	]
},
{ "keys": "alt+o"], "command": "switch_file", "args": {"extensions": "pks", "pkb"]}, "context":
	
		{ "key": "selector", "operator": "equal", "operand": "source.sql" }
	]
}

][/code]

0 Likes

#8

Pffff!
That’s it!

Thanks a lot! :mrgreen:

0 Likes