Sublime Forum

Context operand for the current selection

#1

Hey, I see that when writing context conditions for a keymap, there’s a few operands supported, such as “preceding_text” and “following_text”, but there’s nothing to test the current selection.

Essentially, I’m trying to add a shortcut which replaces the quotes used in a string.

Selection (including the quotes): “foo”
Keypress: ’ (single quote)
Output: ‘foo’

and vice versa.

What I want to do is add a check to the hotkey to see if the selection starts and ends with a single- or double-quote.

0 Likes

#2

I think you want to use the “selector” item to make it match the caret’s scope (Ctrl+Alt+Shift+P).

0 Likes

#3

nope, i’m not worried about the scope of the selection, I just want to test the current selection against a regex, like you can for preceding_text and following_text

0 Likes

#4

I found out that the key is called “text” … duh

0 Likes