Sublime Forum

Build System Variables for selected text within a file

#1

Hello,

I wonder if it would be possible to add two variables to the build system. $selection_start and $selection_length.
$selection_start would be the (zero-based) index of the first selected character within $file.
$selection_length would be the count of selected characters from $selection_start within $file.
If there is no current selection (or when there are multiple), $selection_length would be zero, and $selection_start would be the current caret position (or zero).

I am a SQL developer by trade and often work with large scripts containing many different queries. I’m currently using a simple query runner to execute script files as a whole, which works fine, but forces me to copy/paste (sub)queries to seperate files when I want to run them in isolation. The above addition would allow me to have my query runner execute just the selected part of a script file, which would save me a lot of time.

Regards,

Peter.

1 Like

Execute programs with parameters from text line?
#2

I don’t know much about SQL, but I wrote something similar for Python.

1 Like

#3

So, perform the selection query as a plugin, rather than a build system? I had not thought of that. Thank you for the suggestion. I will see if I can work this out (as I don’t know much about python).

Cheers,

Peter.

0 Likes

#4

a build system can use a custom command (just like any plugin), so you can still use the build system to execute only the selected text

1 Like