Sublime Forum

How to catch a quote character in a keybinding

#1

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: “”, 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

0 Likes

#2

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:

For a quote character:
args:

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

Hope that gives you some idea…

Edan

0 Likes

#3

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.

0 Likes

#4

So has this been added Jon? I remember running into this before too.

0 Likes

#5

Yep, this was fixed in 20100411

0 Likes