Home Download Buy Blog Forum Support

How to catch a quote character in a keybinding

How to catch a quote character in a keybinding

Postby edanm on Sat Apr 03, 2010 7:53 pm

Hi everyone,

I'm working on my first few plugins for Sublime Text.

Right now, I'm stuck with the following problem: I want my plugin to capture the next character the user types, after hitting the shortcut for my plugin (ctrl+t, for example).
So I already figured out that I can use regex matching for that, like so: "<binding key="ctrl+t,/./" command="forwardTillChar $1"/>", where my command will be getting the next key typed as args[0].

However, this doesn't seem to work when the next character typed is a quote character (or a space character, for that matter).

Any ideas what I can do?

Thanks,
Edan
edanm
 
Posts: 131
Joined: Thu Mar 04, 2010 11:05 pm

Re: How to catch a quote character in a keybinding

Postby edanm on Sun Apr 04, 2010 6:37 pm

Thanks, but it didn't seem to work.

Bit more info: when I print the args list out in my function, here's what I get for each input:

For a normal character (e.g., '('):
args: [u'(']

For a quote character:
args: [u'']

For a space character (also something I want to be able to catch):
args: []

Hope that gives you some idea...

Edan
edanm
 
Posts: 131
Joined: Thu Mar 04, 2010 11:05 pm

Re: How to catch a quote character in a keybinding

Postby jps on Sat Apr 10, 2010 4:21 am

The captured character is being passed raw into the command, where it runs into the command parser before being handed over to the command itself, so spaces, quotes, and backslashes all have special meaning.

I'll change the next beta to instead escape and quote the captured text (as it always should have), so it'll be passed into the command as expected. In the mean time, you could work around it to some degree by replacing the $0 with a '$0', which will allow spaces and double quotes to work properly, at least.
jps
Site Admin
 
Posts: 3058
Joined: Wed Mar 19, 2008 12:33 pm

Re: How to catch a quote character in a keybinding

Postby willi297 on Sat Jul 10, 2010 9:17 pm

So has this been added Jon? I remember running into this before too.
Greg Williams
Atomic Embedded, USA
http://atomicembedded.com
willi297
 
Posts: 121
Joined: Wed Nov 18, 2009 8:29 pm
Location: Grand Rapids, MI, USA

Re: How to catch a quote character in a keybinding

Postby jps on Sun Aug 15, 2010 1:27 am

Yep, this was fixed in 20100411
jps
Site Admin
 
Posts: 3058
Joined: Wed Mar 19, 2008 12:33 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests